mirror of
https://github.com/django/django.git
synced 2025-08-04 19:08:28 +00:00
Fixed #15185 -- Allowed ModelAdmin.list_display_links=None to disable change list links.
Thanks rm_ for the suggestion.
This commit is contained in:
parent
bf757a2f4d
commit
1d0fc61b1c
8 changed files with 83 additions and 26 deletions
|
@ -648,19 +648,21 @@ subclass::
|
|||
|
||||
.. attribute:: ModelAdmin.list_display_links
|
||||
|
||||
Set ``list_display_links`` to control which fields in ``list_display``
|
||||
should be linked to the "change" page for an object.
|
||||
Use ``list_display_links`` to control if and which fields in
|
||||
:attr:`list_display` should be linked to the "change" page for an object.
|
||||
|
||||
By default, the change list page will link the first column -- the first
|
||||
field specified in ``list_display`` -- to the change page for each item.
|
||||
But ``list_display_links`` lets you change which columns are linked. Set
|
||||
``list_display_links`` to a list or tuple of fields (in the same
|
||||
format as ``list_display``) to link.
|
||||
But ``list_display_links`` lets you change this:
|
||||
|
||||
``list_display_links`` can specify one or many fields. As long as the
|
||||
fields appear in ``list_display``, Django doesn't care how many (or
|
||||
how few) fields are linked. The only requirement is: If you want to use
|
||||
``list_display_links``, you must define ``list_display``.
|
||||
* Set it to ``None`` to get no links at all.
|
||||
* Set it to a list or tuple of fields (in the same format as
|
||||
``list_display``) whose columns you want converted to links.
|
||||
|
||||
You can specify one or many fields. As long as the fields appear in
|
||||
``list_display``, Django doesn't care how many (or how few) fields are
|
||||
linked. The only requirement is that if you want to use
|
||||
``list_display_links`` in this fashion, you must define ``list_display``.
|
||||
|
||||
In this example, the ``first_name`` and ``last_name`` fields will be
|
||||
linked on the change list page::
|
||||
|
@ -669,7 +671,17 @@ subclass::
|
|||
list_display = ('first_name', 'last_name', 'birthday')
|
||||
list_display_links = ('first_name', 'last_name')
|
||||
|
||||
.. _admin-list-editable:
|
||||
In this example, the change list page grid will have no links::
|
||||
|
||||
class AuditEntryAdmin(admin.ModelAdmin):
|
||||
list_display = ('timestamp', 'message')
|
||||
list_display_links = None
|
||||
|
||||
.. versionchanged:: 1.7
|
||||
|
||||
``None`` was added as a valid ``list_display_links`` value.
|
||||
|
||||
.. _admin-list-editable:
|
||||
|
||||
.. attribute:: ModelAdmin.list_editable
|
||||
|
||||
|
@ -1242,9 +1254,13 @@ templates used by the :class:`ModelAdmin` views:
|
|||
|
||||
The ``get_list_display_links`` method is given the ``HttpRequest`` and
|
||||
the ``list`` or ``tuple`` returned by :meth:`ModelAdmin.get_list_display`.
|
||||
It is expected to return a ``list`` or ``tuple`` of field names on the
|
||||
changelist that will be linked to the change view, as described in the
|
||||
:attr:`ModelAdmin.list_display_links` section.
|
||||
It is expected to return either ``None`` or a ``list`` or ``tuple`` of field
|
||||
names on the changelist that will be linked to the change view, as described
|
||||
in the :attr:`ModelAdmin.list_display_links` section.
|
||||
|
||||
.. versionchanged:: 1.7
|
||||
|
||||
``None`` was added as a valid ``get_list_display_links()`` return value.
|
||||
|
||||
.. method:: ModelAdmin.get_fields(self, request, obj=None)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue