{{{#!python
# models
from django.db import models
class Question(models.Model):
question_text = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
}}}
{{{#!python
# admin
from django.contrib import admin
from .models import Question
class QuestionAdmin(admin.ModelAdmin):
# list_display = ['id', 'pub_date', 'question_text']
list_display_links = ['id', 'pub_date', 'question_text',]
def get_list_display(self, request):
return ['id', 'pub_date', 'question_text']
admin.site.register(Question, QuestionAdmin)
}}}
{{{
$ python manage.py check
SystemCheckError: System check identified some issues:
ERRORS:
<class 'myapp.admin.QuestionAdmin'>: (admin.E111) The value of
'list_display_links[0]' refers to 'id', which is not defined in
'list_display'.
<class 'myapp.admin.QuestionAdmin'>: (admin.E111) The value of
'list_display_links[1]' refers to 'pub_date', which is not defined in
'list_display'.
<class 'myapp.admin.QuestionAdmin'>: (admin.E111) The value of
'list_display_links[2]' refers to 'question_text', which is not defined in
'list_display'.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26632>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* component: Uncategorized => contrib.admin
* needs_tests: => 0
* needs_docs: => 0
* type: Uncategorized => Bug
* stage: Unreviewed => Accepted
Comment:
I don't think we can check these methods because we'd need an
`HttpRequest`.
As [https://groups.google.com/d/msg/django-developers/WrnhmTyLHuY/LI-
MROj_J1cJ Luke said], "I think the problems with the false negatives for
the admin checks may need to be solved another way - namely by removing
them. That's unfortunate, but I found them tricky in the past - they may
prevent common errors, but they also prevent more advanced ways that you
might want to use the admin."
Maybe we could try disabling each check if the method version of check's
attribute is defined.
--
Ticket URL: <https://code.djangoproject.com/ticket/26632#comment:1>
* cc: desecho@… (added)
* has_patch: 0 => 1
* version: 1.9 => master
Comment:
Added [https://github.com/django/django/pull/7620 PR].
--
Ticket URL: <https://code.djangoproject.com/ticket/26632#comment:2>
Comment (by Simon Charette):
What about adding a hint to the error that you should override
`get_list_display_link()` to return dynamic results if
`get_list_display()` was overrode?
--
Ticket URL: <https://code.djangoproject.com/ticket/26632#comment:3>
* needs_tests: 0 => 1
Comment:
A test is also needed.
--
Ticket URL: <https://code.djangoproject.com/ticket/26632#comment:4>
Comment (by Anton Samarchyan):
Replying to [comment:3 Simon Charette]:
> What about adding a hint to the error that you should override
`get_list_display_link()` to return dynamic results if
`get_list_display()` was overrode?
Currently, I silence all errors if get_list_display() is overridden. Do
you want to bring the errors back or create a new error or else?
--
Ticket URL: <https://code.djangoproject.com/ticket/26632#comment:5>
* needs_tests: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/26632#comment:6>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"da792400503265a80e5307f17e59b65ec88694aa" da792400]:
{{{
#!CommitTicketReference repository=""
revision="da792400503265a80e5307f17e59b65ec88694aa"
Fixed #26632 -- Skipped admin.E111 list_display_links check if
get_list_display() is overridden.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26632#comment:7>