Opened 6 years ago

Closed 3 years ago

Last modified 3 years ago

#15185 closed New feature (fixed)

Ability to make all list_display fields not clickable

Reported by: rm_ Owned by: petter
Component: contrib.admin Version: 1.2
Severity: Normal Keywords: list_display_links
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: yes


I have a model to store logs which have only not editable or auto-added fields which by default are not shown in a ModelAdmin; when i click in the admin interface the first element of list_display an empty form is shown which is very confusing for the user. I thoughtd that an empty list_display_links would make it but does not work as i expect. I can workaround this with some js but something from the django side would be handy.

Change History (13)

comment:1 Changed 6 years ago by Russell Keith-Magee

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted

It's an edge case, but I can't see a reason to disallow it. An empty ModelAdmin.list_display_links should disable *all* links, rather than forcing the first link to be a list.

I'm going to guess that this is a case of a check doing "if list_display_list:", rather than "if list_display_list is None".

As a workaround in the meantime, you may want to consider using readonly_fields to define a list of fields to display on the form -- not a perfect solution, but probably less confusing than an empty form.

comment:2 Changed 6 years ago by Julien Phalip

There is another piece of inconsistency in the current behaviour, I think. Here typically you seem to want to disallow any editing but allow the listing of your records, which sounds perfectly reasonable. However, if you override ModelAdmin.has_change_permission() to return False (as a way of disabling editing) then the list view is disabled altogether.

So I'm not sure what the most sensible approach would be between:

(1) As originally suggested, keep the change permission enabled and somehow disable list_display_links.

(2) Make it so that if the change permission is disabled, you cannot edit records (either via the list view's edit inline feature or via a single record's change view) but you still can list your records.

If (2) is addressed, then one might argue that we'd need to introduce another standard permission (list), which may break backwards compatibility. But if (1) is addressed, then note that this wouldn't prevent users to manually type in the URL to access a record's change view.

comment:3 Changed 6 years ago by Julien Phalip

See #11561 for another use case where the has_change_permission gets in the way of displaying the change list.

comment:4 Changed 6 years ago by Łukasz Rekucki

Severity: Normal
Type: New feature

comment:5 Changed 5 years ago by Julien Phalip

UI/UX: set

comment:6 Changed 5 years ago by Julien Phalip

Easy pickings: unset

On a related note, see #8936 about adding view-only functionality to the admin.

comment:7 Changed 5 years ago by Julien Phalip

#16765 is a dupe.

comment:8 Changed 4 years ago by petter

Owner: changed from nobody to petter
Status: newassigned

comment:9 Changed 3 years ago by Ramiro Morales

What about fixing this by allowing assigning None to list_display_links?.

It would be consistent with actions and would allow to solve this presentation issue without having to wait for another, greater design decision and change about if the admin app can be use as a browse-only tool.

Last edited 3 years ago by Ramiro Morales (previous) (diff)

comment:10 Changed 3 years ago by Ramiro Morales

See PR implementing last comment proposal at

comment:11 Changed 3 years ago by Tim Graham

Has patch: set
Triage Stage: AcceptedReady for checkin

comment:12 Changed 3 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: assignedclosed

In 1d0fc61b1cadee584a27dbbe3ef3e21fd3202c85:

Fixed #15185 -- Allowed ModelAdmin.list_display_links=None to disable change list links.

Thanks rm_ for the suggestion.

comment:13 Changed 3 years ago by rm_

Thanks to all the people involved in getting this in!

Note: See TracTickets for help on using tickets.
Back to Top