[Django] #33642: Can't create objects with Postgres range fields without upper and lower bounds in the admin

13 views
Skip to first unread message

Django

unread,
Apr 13, 2022, 7:45:14 AM4/13/22
to django-...@googlegroups.com
#33642: Can't create objects with Postgres range fields without upper and lower
bounds in the admin
--------------------------------------------+------------------------
Reporter: Tom Carrick | Owner: (none)
Type: Bug | Status: new
Component: contrib.postgres | Version: dev
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 1 |
--------------------------------------------+------------------------
There is some funky behaviour when using Postgres range fields in the
admin.

I only tested with DateTimeRangeField but I imagine it's the same for the
others.

----

Using `period = DateTimeRangeField()`:

Trying to add an item without lower and upper bounds results in an error
that the field is required.

Adding an item with a lower bound but no upper bound, or vice versa does
work.

----

Using `period = DateTimeRangeField(blank=True, null=True)`:

Adding an item without any bound gives a null for the column, which is not
always what I want.

----

Using `period = DateTimeRangeField(blank=True)`:

Tries to do as above but fails on the null constraint.

----

I imagine this needs a bit of UX thought as it should be possible to do
either: set the column to null or set the column to a range with null as
both bounds.

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

Django

unread,
Apr 20, 2022, 2:02:38 AM4/20/22
to django-...@googlegroups.com
#33642: Can't create objects with Postgres range fields without upper and lower
bounds in the admin
----------------------------------+--------------------------------------

Reporter: Tom Carrick | Owner: (none)
Type: Bug | Status: closed
Component: contrib.postgres | Version: dev
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: 1
----------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

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


Comment:

> Using `period = DateTimeRangeField()`:
>
> Trying to add an item without lower and upper bounds results in an error
that the field is required.
>
> Adding an item with a lower bound but no upper bound, or vice versa does
work.

As far as I'm aware, it's an expected behavior.

> Using `period = DateTimeRangeField(blank=True, null=True)`:
>
> Adding an item without any bound gives a null for the column, which is
not always what I want.

What would you expect instead of `NULL`? 🤔

> Using `period = DateTimeRangeField(blank=True)`:
>
> Tries to do as above but fails on the null constraint.

This is also en expected and
[https://docs.djangoproject.com/en/4.0/ref/models/fields/#blank
documented] behavior, see also #6189.

> I imagine this needs a bit of UX thought as it should be possible to do
either: set the column to null or set the column to a range with null as
both bounds.

Do you have any non-misleading UX proposition? This seems tricky. There is
also some overlap with #29656. Maybe we should continue the discussion
there.

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

Reply all
Reply to author
Forward
0 new messages