Search code examples
djangovalidationmodels

Django DateField doesn't allow blank=True


For some reason, even with null=True and blank=True, my form will still not validate without me filling out the application_due-field.

Any ideas?

application_due = models.DateField(_('Application Due'), null=True, blank=True)

Here's my form.py:

application_due = forms.DateField(input_formats=['%d-%m-%Y', '%d/%m/%Y'], widget=DateInput(format='%d-%m-%Y', attrs={'placeholder': 'Application due (DD-MM-YYYY)'}))

Solution

  • Try add this attribute to form field definition:

    required=False