Opened 12 years ago

Closed 9 years ago

#2871 closed defect (worksforme)

DateTime fields are not checked when updating object

Reported by: mikhail@… Owned by: nobody
Component: contrib.admin Version:
Severity: normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I created an object, but after that I updated it in Django admin and edited DateTimeField to 2006-02-31 00:00:00. In database there is 0000-00-00 00:00:00, and I get an exception when refering to object:

ValueError at /games/game/1/
year is out of range
Request Method: 	POST
Request URL: 	http://localhost:8000/games/game/1/
Exception Type: 	ValueError
Exception Value: 	year is out of range
Exception Location: 	/usr/lib/python2.4/site-packages/MySQLdb/ in defaulterrorhandler, line 33

Please verify that the date is correct before inserting/updating. See function time.strptime in Python.

Also IntegerField (and PositiveIntegerField) is not checked but simply substituted by database to 231-1 if larger during inserting/updating.

Change History (3)

comment:1 Changed 12 years ago by Chris Beaven

Component: ValidatorsAdmin interface
Triage Stage: UnreviewedAccepted

This should be caught by validation. Probably this will fix itself with the newforms-branch

comment:2 Changed 12 years ago by James Bennett

Yeah, this is something we need to catch at the form validation stage. Might be worth working up a torture test of cases where MySQL will corrupt incoming data without raising an error, and running newforms through it.

comment:3 Changed 9 years ago by stephanhoyer

Resolution: worksforme
Status: newclosed

I just tested it, form was validated correctly.

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