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>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
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>
* cc: felixxm (added)
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/28958#comment:2>
* severity: Normal => Release blocker
Comment:
It's a bug in a new feature in 2.0 (#28335).
--
Ticket URL: <https://code.djangoproject.com/ticket/28958#comment:3>
* status: new => assigned
* owner: nobody => felixxm
--
Ticket URL: <https://code.djangoproject.com/ticket/28958#comment:4>
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/9491 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/28958#comment:5>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"c8152137400b5932578cd1788b79560c9772e56b" c815213]:
{{{
#!CommitTicketReference repository=""
revision="c8152137400b5932578cd1788b79560c9772e56b"
Fixed #28958 -- Fixed admin changelist crash when using a query expression
in the page's ordering.
Thanks Tim Graham for the review.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/28958#comment:6>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"b54302d2269e54cfc2a9594b1f3e652e1fd089ed" b54302d2]:
{{{
#!CommitTicketReference repository=""
revision="b54302d2269e54cfc2a9594b1f3e652e1fd089ed"
[2.0.x] Fixed #28958 -- Fixed admin changelist crash when using a query
expression in the page's ordering.
Thanks Tim Graham for the review.
Backport of c8152137400b5932578cd1788b79560c9772e56b from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/28958#comment:7>
Comment (by GitHub <noreply@…>):
In [changeset:"1d00923848d504c6132019492b8d5a6cdf8261db" 1d00923]:
{{{
#!CommitTicketReference repository=""
revision="1d00923848d504c6132019492b8d5a6cdf8261db"
Refs #28958 -- Added a test for ModelAdmin with query expressions in
ordering.
This provides additional test coverage but isn't a regression test for
the ticket's issue.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/28958#comment:8>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"8f67eeaef44ae8f1fcb51588a65f7818e4d7a967" 8f67eea]:
{{{
#!CommitTicketReference repository=""
revision="8f67eeaef44ae8f1fcb51588a65f7818e4d7a967"
[2.0.x] Refs #28958 -- Added a test for ModelAdmin with query expressions
in ordering.
This provides additional test coverage but isn't a regression test for
the ticket's issue.
Backport of 1d00923848d504c6132019492b8d5a6cdf8261db from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/28958#comment:9>