Opened 18 years ago

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

Description

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 )
m.save()

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@…> 18 years ago.

Download all attachments as: .zip

Change History (3)

by Honza Král <Honza.Kral@…>, 18 years ago

Attachment: interger_field.patch added

comment:1 by Chris Beaven, 18 years ago

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

comment:2 by Adrian Holovaty, 18 years ago

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