Opened 13 years ago

Closed 10 years ago

Last modified 10 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

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 by Russell Keith-Magee, 13 years ago

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 by Julien Phalip, 13 years ago

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 by Julien Phalip, 13 years ago

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

comment:4 by Łukasz Rekucki, 13 years ago

Severity: Normal
Type: New feature

comment:5 by Julien Phalip, 13 years ago

UI/UX: set

comment:6 by Julien Phalip, 13 years ago

Easy pickings: unset

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

comment:7 by Julien Phalip, 13 years ago

#16765 is a dupe.

comment:8 by petter, 11 years ago

Owner: changed from nobody to petter
Status: newassigned

comment:9 by Ramiro Morales, 11 years ago

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 11 years ago by Ramiro Morales (previous) (diff)

comment:10 by Ramiro Morales, 11 years ago

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

comment:11 by Tim Graham, 11 years ago

Has patch: set
Triage Stage: AcceptedReady for checkin

comment:12 by Tim Graham <timograham@…>, 10 years ago

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 by rm_, 10 years ago

Thanks to all the people involved in getting this in!

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