#22792 closed Bug (fixed)
Check rule for list_display_links is incorrect
Reported by: | Ben Davis | Owned by: | Greg Chapple |
---|---|---|---|
Component: | contrib.admin | Version: | 1.7-beta-2 |
Severity: | Release blocker | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
This use case should be allowed according to the documentation:
@admin.register(products.Product) class ModelAdmin(admin.ModelAdmin): list_display = ['brand', 'product', 'category'] list_editable = list_display list_display_links = None
However, checks will fail saying:
<class 'products.admin.ProductAdmin'>: (admin.E124) The value of 'list_editable[0]' refers to the first field in 'list_display' ('brand'), which cannot be used unless 'list_display_links' is set.
I think this check is a mistake. What it should be checking for is this: If the first values of list_editable
and list_display
are the same, list_display_links must be either set to None, or must be set to a field other than the first field in list_display
.
Change History (8)
comment:1 by , 10 years ago
Severity: | Normal → Release blocker |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 10 years ago
Has patch: | set |
---|
Created a PR here: https://github.com/django/django/pull/2786
The use case given above now works, and admin.E123
has also been fixed.
comment:4 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:7 by , 8 years ago
Replying to Tim Graham <timograham@…>:
…65bd053f…
Can we get this backported to 1.8?
- cls.list_display_links is not None): + not cls.list_display_links and cls.list_display_links is not None):
comment:8 by , 8 years ago
Per our supported versions policy, 1.8 is only receiving fixes for security and data loss issues.
Another issue we should also fix is in the previous check
admin.E123
-- it should beelif cls.list_display_links and field_name in cls.list_display_links
so that iflist_display_links
isNone
there isn't aTypeError: argument of type 'NoneType' is not iterable
error.