[patch] entering an invalid day of month for DateField and DateTimeField fields results in NULL value
If you try to enter a date where the day is out of range for the month, like 2006-11-31
, django will try to insert a NULL value for that field. These dates get past the isValidANSIDate
validator's regular expression. Maybe it would be best to use another validator that uses datetime, as it knows that this is an invalid date...
>>> datetime.datetime(2006,11,31)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ValueError: day is out of range for month
and isValidANSIDate
could use a simpler regular expression that just checks for a YYYY-MM-DD
format.
Change History
(4)
Summary: |
entering an invalid day of month for DateField and DateTimeFields fields results in NULL value → entering an invalid day of month for DateField and DateTimeField fields results in NULL value
|
Summary: |
entering an invalid day of month for DateField and DateTimeField fields results in NULL value → [patch] entering an invalid day of month for DateField and DateTimeField fields results in NULL value
|
Resolution: |
→ fixed
|
Status: |
new → closed
|
(In [3815]) Fixed #2674 -- Added stricter date validation so that things like 2006-11-31
are caught. Thanks, Gary Wilson.