0

I have a date data type in one of my class and it is optional, so I set null=True. but when the user input nothing for the date and submit the info, I get the error message of

[u"'' value has an invalid date format. It must be in YYYY-MM-DD format."]

Field :birthday=models.DateField(null=True)

HTML code is as below.

<div> <label>Birthday:</label> <input type="date" id="id_bd" name="bd"> </div>

Can anyone explain to me why this would happen and how am I going to handle this null input error? Thank you very much.

Mona
  • 1,425
  • 6
  • 21
  • 31
  • possible duplicate of [differentiate null=True, blank=True in django](http://stackoverflow.com/questions/8609192/differentiate-null-true-blank-true-in-django) – Burhan Khalid Jun 06 '13 at 07:42

1 Answers1

0

Your question is answered here, but the short version is null=True defines what happens in the database it sets the default value to NULL, and blank=True defines if the form field is required or not.

Community
  • 1
  • 1
Burhan Khalid
  • 169,990
  • 18
  • 245
  • 284