Opened 10 years ago

Closed 10 years ago

#9654 closed (wontfix)

`list_display_links` does not respect an empty tuple.

Reported by: mdh Owned by: nobody
Component: contrib.admin Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


The admin's change list page will link the first column to the change page for each item even if you explicitly specify an empty tuple as the value of list_display_links. Although it is unusual not to want any of the columns to link to the default change page, this can come up if you are using other extensions to the admin to build a custom interface for a given model. The underlying issue is very easy to address: it arises because the admin uses an empty tuple as the default value, when it could just as easily have used None as the default value instead.

I've attached a simple patch. It's not obvious to me how to test this with the test fixtures currently available, so I haven't written any tests. If people like this but think it needs tests and can give me a hint about how to approach them I'd be happy to write them.

Attachments (1)

respect-empty-list_display_links.diff (1.9 KB) - added by mdh 10 years ago.

Download all attachments as: .zip

Change History (3)

Changed 10 years ago by mdh

comment:1 Changed 10 years ago by Karen Tracey

Not sure I'd say I like the idea -- the use case is still a bit vague to me -- but stuff like this can be tested. Look in regressiontests/admin_views, there are tests there that request admin pages and check the response to make sure it has some text, or doesn't have some text, has ordered items in a particular way, etc.

comment:2 Changed 10 years ago by Jacob

Resolution: wontfix
Status: newclosed

list_display_links (like the other options) is a shortcut; use a custom template if they don't go far enough.

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