I'm using the following form field definitions,
start_date = django.forms.DateField(
label=_("Start date"),
initial=timezone.now().date(),
widget=django.forms.DateInput(format = '%Y/%m/%d'))
end_date = django.forms.DateField(
label=_("End date"),
initial=None,
required=False,
widget=django.forms.DateInput(format = '%Y/%m/%d'))
Since I set the initial for start_date
, it shows up on the form with the default value, something like "2013/06/25".
If I just click on submit, it immediately tells me this error:
Start date: Enter a valid date.
This is without me even doing anything! How is it that an initial value assigned by Forms according to the pre-defined format FAIL the validation ?!
Maybe
'%Y/%m/%d'
is not in theDateField
'sinput_formats
list. You can try to add it like this:Hope this helps!