Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#18724 closed Bug (fixed)

Model field validation for IntegerFields does not validate 0 against choices

Reported by: bremac 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

Description

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 3 years ago by bremac

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 3 years ago by claudep

  • Triage Stage changed from Unreviewed to Accepted

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

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

In [ad237fb72f769bbd99b5ed6e3292bead614e1c94]:

Fixed #18724 -- Fixed IntegerField validation with value 0

comment:4 Changed 3 years ago by mihaicc

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

comment:5 Changed 3 years ago by claudep

No, it will be in 1.5

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