Code

Opened 2 years ago

Closed 2 years ago

Last modified 22 months 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.

Attachments (0)

Change History (5)

comment:1 Changed 2 years ago by bremac

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

comment:2 Changed 2 years ago by claudep

  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 2 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 22 months ago by mihaicc

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

comment:5 Changed 22 months ago by claudep

No, it will be in 1.5

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.