Opened 6 years ago

Last modified 6 years ago

#30201 closed Bug

Form with IntegerRangeField does not validate — at Version 1

Reported by: George Tantiras Owned by: nobody
Component: contrib.postgres Version: 2.1
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by George Tantiras)

In a fresh Django installation:

from django import forms
from django.contrib.postgres.forms import IntegerRangeField
from psycopg2.extras import NumericRange


class A(forms.Form):
    lifespan = IntegerRangeField(required=True)


>>> data = {'lifespan': NumericRange(1918, 1999)} 
>>> p = A(data=data)
>>> p.data
{'lifespan': NumericRange(1918, 1999, '[)')}
>>> p.is_valid()
False
>>> p.errors
{'lifespan': ['This field is required.']}
>>> p.cleaned_data
{}

I discovered this behaviour while trying to test the clean method of a ModelForm with this field.

Change History (1)

comment:1 by George Tantiras, 6 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top