Opened 18 years ago

Closed 18 years ago

Last modified 18 years ago

#2674 closed defect (fixed)

[patch] entering an invalid day of month for DateField and DateTimeField fields results in NULL value

Reported by: Gary Wilson <gary.wilson@…> Owned by: Adrian Holovaty
Component: contrib.admin Version: dev
Severity: normal Keywords:
Cc: gary.wilson@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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.

Attachments (1)

dates.diff (2.1 KB ) - added by Gary Wilson <gary.wilson@…> 18 years ago.

Download all attachments as: .zip

Change History (4)

comment:1 by anonymous, 18 years ago

Summary: entering an invalid day of month for DateField and DateTimeFields fields results in NULL valueentering an invalid day of month for DateField and DateTimeField fields results in NULL value

by Gary Wilson <gary.wilson@…>, 18 years ago

Attachment: dates.diff added

comment:2 by Gary Wilson <gary.wilson@…>, 18 years ago

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

comment:3 by Malcolm Tredinnick, 18 years ago

Resolution: fixed
Status: newclosed

(In [3815]) Fixed #2674 -- Added stricter date validation so that things like 2006-11-31
are caught. Thanks, Gary Wilson.

Note: See TracTickets for help on using tickets.
Back to Top