Code

Opened 8 years ago

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

Download all attachments as: .zip

Change History (3)

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

comment:1 Changed 8 years ago by SmileyChris

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

comment:2 Changed 8 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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.