mirror of
https://github.com/django/django.git
synced 2025-08-03 02:23:12 +00:00
[1.5.x] Fixed #17646 -- Added a get_list_filter() method to ModelAdmin. Thanks to rasca for the suggestion and to mateusgondim for the patch.
Backport of ae206d78f6
This commit is contained in:
parent
02ab5d180e
commit
22ca5bab95
5 changed files with 58 additions and 4 deletions
|
@ -570,8 +570,8 @@ subclass::
|
|||
|
||||
.. image:: _images/users_changelist.png
|
||||
|
||||
``list_filter`` should be a list of elements, where each element should be
|
||||
of one of the following types:
|
||||
``list_filter`` should be a list or tuple of elements, where each element
|
||||
should be of one of the following types:
|
||||
|
||||
* a field name, where the specified field should be either a
|
||||
``BooleanField``, ``CharField``, ``DateField``, ``DateTimeField``,
|
||||
|
@ -1076,6 +1076,14 @@ templates used by the :class:`ModelAdmin` views:
|
|||
changelist that will be linked to the change view, as described in the
|
||||
:attr:`ModelAdmin.list_display_links` section.
|
||||
|
||||
.. method:: ModelAdmin.get_list_filter(self, request)
|
||||
|
||||
.. versionadded:: 1.5
|
||||
|
||||
The ``get_list_filter`` method is given the ``HttpRequest`` and is expected
|
||||
to return the same kind of sequence type as for the
|
||||
:attr:`~ModelAdmin.list_filter` attribute.
|
||||
|
||||
.. method:: ModelAdmin.get_inline_instances(self, request, obj=None)
|
||||
|
||||
.. versionadded:: 1.5
|
||||
|
|
|
@ -318,6 +318,9 @@ Django 1.5 also includes several smaller improvements worth noting:
|
|||
:func:`django.contrib.messages.add_message`. This is useful for generating
|
||||
error messages from admin actions.
|
||||
|
||||
* The admin's list filters can now be customized per-request thanks to the new
|
||||
:meth:`django.contrib.admin.ModelAdmin.get_list_filter` method.
|
||||
|
||||
Backwards incompatible changes in 1.5
|
||||
=====================================
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue