I am trying to validate a User Profiling form in django and I can\'t. It seems that there is something wrong with forms.dateField(). It does not validate (ie. is_valid() ret
input formats in DateField must be list or tuple https://docs.djangoproject.com/en/dev/ref/forms/fields/#django.forms.DateField.input_formats
With Django 1.6 and up you can use the localized_fields
in your form's Meta or localize=True
in your form. See https://docs.djangoproject.com/en/1.9/topics/i18n/formatting/#format-localization.
When using USE_L10N = True
, Django will use the formats.py
file for your locale (part of LANGUAGE_CODE
).
You can end up with something DRY like this (as the fields
specified in models.py
do not need to be repeated in forms.py
):
class SomeForm(forms.Form):
class Meta:
model = SomeModel
fields = ('first_name', 'dob',)
localized_fields = ('dob',)