Opened 18 years ago

Closed 18 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: dev
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: no UI/UX: no

Description

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)

__init__.py.diff (2.7 KB ) - added by Brantley <deadwisdom@…> 18 years ago.
/django/db/models/fields/init.py
__init__.py.2.diff (1000 bytes ) - added by Brantley <deadwisdom@…> 18 years ago.
/django/db/models/fields/__init.py__

Download all attachments as: .zip

Change History (5)

by Brantley <deadwisdom@…>, 18 years ago

Attachment: __init__.py.diff added

/django/db/models/fields/init.py

by Brantley <deadwisdom@…>, 18 years ago

Attachment: __init__.py.2.diff added

/django/db/models/fields/__init.py__

comment:1 by Brantley <deadwisdom@…>, 18 years ago

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 by Chris Beaven, 18 years ago

Triage Stage: UnreviewedReady for checkin

Makes sense

comment:3 by Russell Keith-Magee, 18 years ago

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