{{{
#!python
@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`.
--
Ticket URL: <https://code.djangoproject.com/ticket/22792>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_docs: => 0
* severity: Normal => Release blocker
* needs_tests: => 0
* stage: Unreviewed => Accepted
Comment:
Another issue we should also fix is in the previous check `admin.E123` --
it should be `elif cls.list_display_links and field_name in
cls.list_display_links` so that if `list_display_links` is `None` there
isn't a `TypeError: argument of type 'NoneType' is not iterable` error.
--
Ticket URL: <https://code.djangoproject.com/ticket/22792#comment:1>
* status: new => assigned
* owner: nobody => gchp
--
Ticket URL: <https://code.djangoproject.com/ticket/22792#comment:2>
* has_patch: 0 => 1
Comment:
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/22792#comment:3>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"d8f19bb3b6f858bef499fdab41948a5a5e8d55aa"]:
{{{
#!CommitTicketReference repository=""
revision="d8f19bb3b6f858bef499fdab41948a5a5e8d55aa"
Fixed #22792 -- Updated checks for list_display_links in model admin
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/22792#comment:4>
Comment (by Tim Graham <timograham@…>):
In [changeset:"d232a5f93f2c0be93b6aa5669e9cba0f328a4a9b"]:
{{{
#!CommitTicketReference repository=""
revision="d232a5f93f2c0be93b6aa5669e9cba0f328a4a9b"
[1.7.x] Fixed #22792 -- Updated checks for list_display_links in model
admin
Backport of d8f19bb3b6 from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/22792#comment:5>
Comment (by Tim Graham <timograham@…>):
In [changeset:"65bd053f11d22bca529f1da895599796fa0f3ee1" 65bd053f]:
{{{
#!CommitTicketReference repository=""
revision="65bd053f11d22bca529f1da895599796fa0f3ee1"
Fixed #26229 -- Improved check for model admin check admin.E124
Refs #22792
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/22792#comment:6>
Comment (by matsaman):
Replying to [comment:6 Tim Graham <timograham@…>]:
> …[changeset:"65bd053f11d22bca529f1da895599796fa0f3ee1" 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):
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/22792#comment:7>
Comment (by Tim Graham):
Per our [https://docs.djangoproject.com/en/dev/internals/release-process
/#supported-versions supported versions policy], 1.8 is only receiving
fixes for security and data loss issues.
--
Ticket URL: <https://code.djangoproject.com/ticket/22792#comment:8>