Opened 9 years ago

Closed 9 years ago

#3408 closed (worksforme)

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

Reported by: Brantley <deadwisdom@…> Owned by: adrian
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@…> 9 years ago.
/django/db/models/fields/ (1000 bytes) - added by Brantley <deadwisdom@…> 9 years ago.

Download all attachments as: .zip

Change History (5)

Changed 9 years ago by Brantley <deadwisdom@…>


Changed 9 years ago by Brantley <deadwisdom@…>


comment:1 Changed 9 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 9 years ago by SmileyChris

  • Triage Stage changed from Unreviewed to Ready for checkin

Makes sense

comment:3 Changed 9 years ago by russellm

  • Resolution set to worksforme
  • Status changed from new to closed

[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