#23497 closed Bug (fixed)
Admin System Checks do not run for custom AdminSite sites
| Reported by: | Andrew Mosson | Owned by: | Andrew Mosson |
|---|---|---|---|
| Component: | Core (System checks) | Version: | 1.7 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
The admin section of the System checks only runs for ModelAdmin subclasses that are registered with the main AdminSite (admin.site.register(...))
To replicate place something similar to the following in a urls.py file
books/admin.py
from django.contrib import admin
class BookAdmin(admin.ModelAdmin):
list_display = 'a field' # intentional error
- urls.py
from django.admin.sites import AdminSite
from books.models import Book
from books.admin import BookAdmin
custom_site = AdminSite()
custom_site.register(Book, BookAdmin)
> python manage.py check
Expect to see an error here (specifically that list display must be a list of a tuple)
In actuality, this runs fine.
One potential fix for this problem would be to create a module level variable in django.contrib.admin.sites (or directly in django.contrib.admin), run the checks on register (this is already being done but the result of the checks are being ignored), and store the results in the module level variable.
Patch with this approach is attached
Change History (8)
comment:1 by , 11 years ago
| Has patch: | set |
|---|
comment:2 by , 11 years ago
Could you submit a PR against Django's master instead? It makes reviewing easier.
comment:4 by , 11 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:5 by , 11 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:6 by , 11 years ago
comment:7 by , 11 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
Patch at https://github.com/amosson/django/tree/ticket_23497