﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
27810	Add query expression support for ModelAdmin list_display's admin_order_field	Andreas Pelme	Andreas Pelme	"Query expressions cannot currently be used with admin_order_field in a callable on list_display. The code expects a string and crashes when an query expression object is passed instead. This example shows the problem:

{{{
def full_name(obj):
    return f'{obj.first_name} {obj.last_name}'
my_callable.admin_order_field = Concat(F('first_name'), F('last_name'))
}}}

... which leads to a crash like this:

{{{
...
    self.queryset = self.get_queryset(request)
  File ""/Users/andreas/code/django/django/contrib/admin/views/main.py"", line 346, in get_queryset
    ordering = self.get_ordering(request, qs)
  File ""/Users/andreas/code/django/django/contrib/admin/views/main.py"", line 260, in get_ordering
    if order_field.startswith('-') and pfx == ""-"":
AttributeError: 'CombinedExpression' object has no attribute 'startswith'
}}}

It would make sense to be able to make use of all the nice stuff that has gone into query expression from the admin in this case! :)"	New feature	closed	contrib.admin	dev	Normal	fixed			Ready for checkin	1	0	0	0	0	0
