#28958 closed Bug (fixed)
Admin changelist crashes when using query expression in the model's Meta.ordering or ModelAdmin.ordering
Reported by: | Gabriel Amram | Owned by: | Mariusz Felisiak |
---|---|---|---|
Component: | contrib.admin | Version: | 2.0 |
Severity: | Release blocker | Keywords: | query expresssion, ordering, admin, meta |
Cc: | Mariusz Felisiak | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Using the newly introduced query-expression ordering feature in either the model's Meta.ordering or in its ModelAdmin causes errors.
Steps to reproduce:
First variant - using the model's Meta.ordering option -
//models.py class Game(models.Model): score = models.IntegerField(null=True) class Meta: ordering = [F("score").desc(nulls_last=True)] ... // admin.py admin.site.register(Game)
Accessing the admin site will now give an AttributeError: 'OrderBy' object has no attribute 'startswith'
Variant 2 - Using the ModelAdmin ordering attribute:
//admin.py class GameAdmin(models.ModelAdmin): ordering = [F("score").desc(nulls_last=True)]
runserver
fails with error: TypeError: argument of type 'OrderBy' is not iterable
Change History (9)
comment:1 by , 7 years ago
Description: | modified (diff) |
---|---|
Summary: | Using query expression in model Meta.ordering causes AttributeError in admin → Using query expression in either the model's Meta.ordering or ModelAdmin.ordering causes an error |
comment:2 by , 7 years ago
Cc: | added |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 7 years ago
Severity: | Normal → Release blocker |
---|---|
Summary: | Using query expression in either the model's Meta.ordering or ModelAdmin.ordering causes an error → Admin changelist crashes when using query expression in the model's Meta.ordering or ModelAdmin.ordering |
comment:4 by , 7 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Note:
See TracTickets
for help on using tickets.
It's a bug in a new feature in 2.0 (#28335).