Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#18724 closed Bug (fixed)

Model field validation for IntegerFields does not validate 0 against choices

Reported by: Brendan MacDonell Owned by: nobody
Component: Database layer (models, ORM) Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


If a model has an IntegerField with a limited set of choices, the choices will not be checked if the model has the value zero. For instance, given the following model:

class M(models.Model):
    number = models.IntegerField(choices=((1, 1),))

M(number=2).full_clean() will raise a ValidationError , while M(number=0).full_clean() will not.

Change History (5)

comment:1 Changed 6 years ago by Brendan MacDonell

Has patch: set

comment:2 Changed 6 years ago by Claude Paroz

Triage Stage: UnreviewedAccepted

comment:3 Changed 6 years ago by Claude Paroz <claude@…>

Resolution: fixed
Status: newclosed

In [ad237fb72f769bbd99b5ed6e3292bead614e1c94]:

Fixed #18724 -- Fixed IntegerField validation with value 0

comment:4 Changed 6 years ago by mihaicc

not fixed in (1, 4, 0, 'final', 0)

comment:5 Changed 6 years ago by Claude Paroz

No, it will be in 1.5

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