summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/contrib/admin/index.txt18
-rw-r--r--docs/releases/2.1.txt3
2 files changed, 21 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
diff --git a/docs/releases/2.1.txt b/docs/releases/2.1.txt
index 33d6982443..414da31109 100644
--- a/docs/releases/2.1.txt
+++ b/docs/releases/2.1.txt
@@ -47,6 +47,9 @@ Minor features
:meth:`.ModelAdmin.get_sortable_by` method allow limiting the columns that
can be sorted in the change list page.
+* The ``admin_order_field`` attribute for elements in
+ :attr:`.ModelAdmin.list_display` may now be a query expression.
+
:mod:`django.contrib.admindocs`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~