Opened 4 years ago

Closed 21 months ago

Last modified 21 months 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

Description

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 4 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

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 4 years ago by julien

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 4 years ago by julien

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

comment:4 Changed 4 years ago by lrekucki

  • Severity set to Normal
  • Type set to New feature

comment:5 Changed 4 years ago by julien

  • UI/UX set

comment:6 Changed 4 years ago by julien

  • Easy pickings unset

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

comment:7 Changed 4 years ago by julien

#16765 is a dupe.

comment:8 Changed 3 years ago by petter

  • Owner changed from nobody to petter
  • Status changed from new to assigned

comment:9 Changed 2 years ago by ramiro

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 22 months ago by ramiro (previous) (diff)

comment:10 Changed 22 months ago by ramiro

See PR implementing last comment proposal at https://github.com/django/django/pull/1596

comment:11 Changed 22 months ago by timo

  • Has patch set
  • Triage Stage changed from Accepted to Ready for checkin

comment:12 Changed 21 months ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from assigned to closed

In 1d0fc61b1cadee584a27dbbe3ef3e21fd3202c85:

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

Thanks rm_ for the suggestion.

comment:13 Changed 21 months ago by rm_

Thanks to all the people involved in getting this in!

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