#28958: Using query expression in either the model's Meta.ordering or
ModelAdmin.ordering causes an error
-------------------------------------+-------------------------------------
Reporter: Gabriel Amram | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 2.0
Severity: Normal | Resolution:
Keywords: query expresssion, | Triage Stage:
ordering, admin, meta | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Gabriel Amram:
Old description:
> When 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`
New description:
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`
--
--
Ticket URL: <https://code.djangoproject.com/ticket/28958#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/071.f3446777f9132865fcb7eb8ee9a8000a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.