diff options
| author | Andreas Pelme <andreas@pelme.se> | 2018-02-16 03:00:31 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-02-15 21:00:31 -0500 |
| commit | e307ff29d28737d5a764ce2fa7db010231d6fc8e (patch) | |
| tree | ac6cf4a88d36e5cb5de2c7a28f32a55ded650bfa /docs/ref | |
| parent | d368784bacc7e58b426f29937ee842aa14d439ad (diff) | |
Fixed #27810 -- Allowed query expressions in admin_order_field.
Diffstat (limited to 'docs/ref')
| -rw-r--r-- | docs/ref/contrib/admin/index.txt | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt index a917498aed..760cce69be 100644 --- a/docs/ref/contrib/admin/index.txt +++ b/docs/ref/contrib/admin/index.txt @@ -745,6 +745,24 @@ subclass:: author_first_name.admin_order_field = 'author__first_name' + :doc:`Query expressions </ref/models/expressions>` may be used in + ``admin_order_field``. For example:: + + from django.db.models import Value + from django.db.models.functions import Concat + + class Person(models.Model): + first_name = models.CharField(max_length=50) + last_name = models.CharField(max_length=50) + + def full_name(self): + return self.first_name + ' ' + self.last_name + full_name.admin_order_field = Concat('first_name', Value(' '), 'last_name') + + .. versionadded:: 2.1 + + Support for expressions in ``admin_order_field`` was added. + * Elements of ``list_display`` can also be properties. Please note however, that due to the way properties work in Python, setting ``short_description`` on a property is only possible when using the |
