Opened 11 years ago

Closed 11 years ago

#3293 closed defect (fixed)

[patch] newforms: IntegerField should return None on empty

Reported by: Honza Král <Honza.Kral@…> Owned by: Adrian Holovaty
Component: Forms Version: master
Severity: normal Keywords: newforms integerfield
Cc: Honza.Kral@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


if integer field is not required and left empty, clean_data contains u'' (an empty string), which will fail when you try to insert it into DB via model as:

m = Model( ** clean-data )

attached patch modifies the behavior of IntegerField to return None, just like DateField etc.

Attachments (1)

interger_field.patch (853 bytes) - added by Honza Král <Honza.Kral@…> 11 years ago.

Download all attachments as: .zip

Change History (3)

Changed 11 years ago by Honza Král <Honza.Kral@…>

Attachment: interger_field.patch added

comment:1 Changed 11 years ago by Chris Beaven

Haven't checked, but this could be the same for booleanfields too.

comment:2 Changed 11 years ago by Adrian Holovaty

Resolution: fixed
Status: newclosed

(In [4312]) Fixed #3293 -- newforms: Changed IntegerField.clean() to return None if field is not required and empty. Thanks, Honza Kral

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