[Django] #28310: (form) RangeFields should handle (None, None) better.

2 views
Skip to first unread message

Django

unread,
Jun 15, 2017, 1:02:23 AM6/15/17
to django-...@googlegroups.com
#28310: (form) RangeFields should handle (None, None) better.
---------------------------------------------+------------------------
Reporter: Matthew Schinckel | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.11
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------------+------------------------
When you clean a RangeField, and pass it in ('', ''), or (None, None), it
falls through to the MultiValueField handling, which, when all values are
empty, treats the cleaned value as empty.

https://github.com/django/django/blob/master/django/forms/fields.py#L992

Thus:


{{{
FloatRangeField().clean([None, None])
}}}

returns `None`, when it really should return FloatRange(None, None).

There is a very large difference between these.

--
Ticket URL: <https://code.djangoproject.com/ticket/28310>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jun 15, 2017, 9:17:59 AM6/15/17
to django-...@googlegroups.com
#28310: form RangeFields should treat (None, None) as Range(None, None) rather than
None
-----------------------------------+--------------------------------------

Reporter: Matthew Schinckel | Owner: nobody
Type: Bug | Status: new
Component: contrib.postgres | Version: 1.11
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by Tim Graham):

* component: Uncategorized => contrib.postgres
* type: Uncategorized => Bug


Old description:

> When you clean a RangeField, and pass it in ('', ''), or (None, None), it
> falls through to the MultiValueField handling, which, when all values are
> empty, treats the cleaned value as empty.
>
> https://github.com/django/django/blob/master/django/forms/fields.py#L992
>
> Thus:
>

> {{{
> FloatRangeField().clean([None, None])
> }}}
>
> returns `None`, when it really should return FloatRange(None, None).
>
> There is a very large difference between these.

New description:

When you clean a `RangeField` and pass it in `('', '')`, or `(None,
None)`, it falls through to the `MultiValueField` handling, which, when
all values are empty,
[https://github.com/django/django/blob/a6b5321ce997b899e540bb427cca98cb2b93a106/django/forms/fields.py#L992
treats the cleaned value as empty].

Thus, `FloatRangeField().clean([None, None])` returns `None`, when it
really should return `FloatRange(None, None)`.

There is a very large difference between these.

--

Comment:

I'm not sure -- could you elaborate on the use case? How can you submit a
`[None, None]` value in an HTML form (or are you also advocating
transforming `['', '']` to `Range(None, None)`)?

--
Ticket URL: <https://code.djangoproject.com/ticket/28310#comment:1>

Django

unread,
Jul 5, 2017, 8:05:19 AM7/5/17
to django-...@googlegroups.com
#28310: form RangeFields should treat (None, None) as Range(None, None) rather than
None
-----------------------------------+--------------------------------------
Reporter: Matthew Schinckel | Owner: nobody
Type: Bug | Status: closed
Component: contrib.postgres | Version: 1.11
Severity: Normal | Resolution: needsinfo

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by Tim Graham):

* status: new => closed
* resolution: => needsinfo


Comment:

(awaiting clarification)

--
Ticket URL: <https://code.djangoproject.com/ticket/28310#comment:2>

Reply all
Reply to author
Forward
0 new messages