#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 <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.e0e27975316f5146ff5e9cd5d9e1ece9%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.