Opened 10 years ago
Closed 10 years ago
#24479 closed New feature (fixed)
Add a system check to prevent defining both ordering and order_with_respect_to
Reported by: | Daniel Hahler | Owned by: | |
---|---|---|---|
Component: | Core (System checks) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | jon.dufresne@…, me@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
(In django/db/models/options.py)
- When
order_with_respect_to
is being used, and value inordering
gets silently overwritten:
self.ordering = ('_order',)
This should be documented.
- Additionally, I am wondering if there should be a warning / hint when this happens, i.e. when
self.ordering
is non-empty. It might be possible to keep any existing values, and prepend/append the_order
value?!
- With that code (
models.Options._prepare
),ordering
gets set to('_order',)
always (see point 1), but the proxy "field" gets only added if there's noOrderWrt
field yet. This could lead to having an invalid setting forordering
, in case there's aOrderWrt
field that's not named_order
?!
I think point 1 should be addressed anyway (apart from what gets done considering 2. and 3.).
Change History (9)
comment:1 by , 10 years ago
Component: | Uncategorized → Core (System checks) |
---|---|
Summary: | models: please document that order_with_respect_to overwrites ordering / add a warning → Add a system check to prevent defining both ordering and order_with_respect_to |
Triage Stage: | Unreviewed → Accepted |
Type: | Bug → New feature |
comment:2 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 10 years ago
Cc: | added |
---|---|
Has patch: | set |
comment:4 by , 10 years ago
Owner: | removed |
---|---|
Status: | assigned → new |
@jdufresne, if you decided to work on ticket, you must mark it is as assigned to yourself, so people will see that someone is working on it now. I spent some time on it today, and, likely, in vain.
comment:6 by , 10 years ago
Cc: | added |
---|
comment:7 by , 10 years ago
Patch needs improvement: | set |
---|
comment:8 by , 10 years ago
Patch needs improvement: | unset |
---|
Updated patch based on feedback from reviews. Added additional tests and docs. All tests are passing.
Note:
See TracTickets
for help on using tickets.
https://github.com/django/django/pull/4343