#30259: admin_order_field not working with properties
-----------------------------------------+------------------------
               Reporter:  Tobias Wiese   |          Owner:  nobody
                   Type:  Bug            |         Status:  new
              Component:  contrib.admin  |        Version:  2.1
               Severity:  Normal         |       Keywords:
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  1
                  UI/UX:  0              |
-----------------------------------------+------------------------
 The `ModelAdmin` class allows to specify properties from the model in
 `list_display`.

 Normally non-fields cannot be sorted. This can be changed by setting
 `admin_order_field`. This doesn't work on properties, while it is possible
 to do so with `short_description`.

 The
 
[[https://github.com/django/django/blob/e4df8e6dc021fa472fa77f9b835db74810184748/django/contrib/admin/utils.py#L345|code]]
 that checks for `short_description` checks if it handles a property and
 returns `attr.fget.short_description` if available.

 The files that check for `admin_order_field` do not handle the case that
 it might be a property.

 The relevant files are probably:
  - django/contrib/admin/views/main.py
 
([[https://github.com/django/django/blob/24b82cd201e21060fbc02117dc16d1702877a1f3/django/contrib/admin/views/main.py|GitHub]])
  - django/contrib/admin/templatetags/admin_list.py
 
([[https://github.com/django/django/blob/0004daa536890fdb389c895baaa21bea6a1f7073/django/contrib/admin/templatetags/admin_list.py|
 GitHub]])

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30259>
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/054.56500f6944a810e9fea80284baecd515%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to