Opened 3 years ago
Closed 3 years ago
#33642 closed Bug (needsinfo)
Can't create objects with Postgres range fields without upper and lower bounds in the admin
Reported by: | Tom Carrick | Owned by: | |
---|---|---|---|
Component: | contrib.postgres | Version: | dev |
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: | yes |
Description
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.
As far as I'm aware, it's an expected behavior.
What would you expect instead of
NULL
? 🤔This is also en expected and documented behavior, see also #6189.
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.