Opened 10 years ago

Closed 10 years ago

#3408 closed (worksforme)

DateField, TimeField, and DateTimeField to_python() handles null values incorrectly

Reported by: Brantley <deadwisdom@…> Owned by: Adrian Holovaty
Component: Database layer (models, ORM) Version: master
Severity: Keywords: to_python, validation, model
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


DateField, TimeField, and DateTimeField all throw errors incorrectly during serialization and validation when they have a null value even if the model specifies that a null value is acceptable. The patch included simply checks for None as the value, then either returns that value, or raises an appropriate validation error if the field cannot be null.

Attachments (2) (2.7 KB) - added by Brantley <deadwisdom@…> 10 years ago.
/django/db/models/fields/ (1000 bytes) - added by Brantley <deadwisdom@…> 10 years ago.

Download all attachments as: .zip

Change History (5)

Changed 10 years ago by Brantley <deadwisdom@…>

Attachment: added


Changed 10 years ago by Brantley <deadwisdom@…>

Attachment: added


comment:1 Changed 10 years ago by Brantley <deadwisdom@…>

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

Whoops, ignore the first file.

Also, come to think of it the TimeField doesn't even have a to_python. I'm not sure why so I didn't add it here.

comment:2 Changed 10 years ago by Chris Beaven

Triage Stage: UnreviewedReady for checkin

Makes sense

comment:3 Changed 10 years ago by Russell Keith-Magee

Resolution: worksforme
Status: newclosed

[4718] added fixes to null handling across the board; [4719] added unit-tests that validate this case specifically.

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