Reputation: 163
The specified value "06-03-2019" does not conform to the required format, "yyyy-MM-dd".
I use Django internationalisation in a webapplication and for some reason suddenly I get this error in the developer tools on a form date input after changing the language to Dutch. On English everything works fine, the error is not shown and date is saved correctly. I use he standard django forms dateInput.
I searched the webs for hours, before turning to your help. Any suggestions would be greatly appreciated!
Thanks.
Upvotes: 0
Views: 1038
Reputation: 163
Actually, what solved the issue was setting it manually the other way around by adding format=('%Y-%m-%d').
for field in date_fields:
self.fields[field].widget = forms.DateInput(
format=('%Y-%m-%d'),
attrs={
'type': 'date',
'class': 'form-control',
'max': now.strftime('%Y-%m-%d'),
'data-msg-min': _("Kies een datum op of na {0}"),
'data-msg-max': _("Kies een datum die niet in de toekomst ligt")
},
)
Upvotes: 1