mirror of
https://github.com/django/django.git
synced 2025-09-07 19:21:13 +00:00
Fixed #30259 -- Added support for admin_order_field attribute on properties in ModelAdmin.list_display.
This commit is contained in:
parent
ea60b7bc74
commit
044cc54420
7 changed files with 36 additions and 4 deletions
|
@ -754,8 +754,9 @@ subclass::
|
|||
|
||||
* 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
|
||||
``property()`` function and **not** with the ``@property`` decorator.
|
||||
``short_description`` or ``admin_order_field`` on a property is only
|
||||
possible when using the ``property()`` function and **not** with the
|
||||
``@property`` decorator.
|
||||
|
||||
For example::
|
||||
|
||||
|
@ -766,6 +767,7 @@ subclass::
|
|||
def my_property(self):
|
||||
return self.first_name + ' ' + self.last_name
|
||||
my_property.short_description = "Full name of the person"
|
||||
my_property.admin_order_field = 'last_name'
|
||||
|
||||
full_name = property(my_property)
|
||||
|
||||
|
|
|
@ -44,7 +44,8 @@ Minor features
|
|||
:mod:`django.contrib.admin`
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* ...
|
||||
* Added support for ``admin_order_field`` attribute on properties in
|
||||
:attr:`.ModelAdmin.list_display`.
|
||||
|
||||
:mod:`django.contrib.admindocs`
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue