My Django model form currently has a date picker that functions perfectly. However, I am looking to set an initial (default) value for it. Below is my current code:
class DatePickerInput(forms.DateInput):
input_type = 'date'
class PDFClassificationForm(forms.ModelForm):
class Meta:
model = Documents
fields = [
'id_documenttype',
'dateenvoi',,
'comment']
widgets = {
'dateenvoi' : DatePickerInput(),
}
I attempted to add 'initial' as a parameter to DatePickerInput() like this:
widgets = {
'dateenvoi' : DatePickerInput(initial= datetime.now().strftime('%d/%m/%y %H:%M:%S')),
}
Unfortunately, this method was unsuccessful. Any suggestions on how to achieve this?