Opened 9 years ago

Closed 9 years ago

#3293 closed defect (fixed)

[patch] newforms: IntegerField should return None on empty

Reported by: Honza Král <Honza.Kral@…> Owned by: adrian
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:

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

Download all attachments as: .zip

Change History (3)

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

comment:1 Changed 9 years ago by SmileyChris

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

comment:2 Changed 9 years ago by adrian

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

(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