Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#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:2 by Simon Charette, 10 years ago

Could you submit a PR against Django's master instead? It makes reviewing easier.

comment:4 by Tim Graham, 10 years ago

Triage Stage: UnreviewedAccepted

comment:5 by Andrew Mosson, 10 years ago

Owner: changed from nobody to Andrew Mosson
Status: newassigned

comment:6 by Berker Peksag, 9 years ago

I've opened PR #3728 to revise PR #3227.

Changes:

  • Fixed merge conflicts
  • Added a release note
  • Rewrote tests
  • Updated commit message as suggested by Tim

comment:7 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: assignedclosed

In b7219c7ba5fdfbf9349948b5a91af50e32822ee6:

Fixed #23497 -- Made admin system checks run for custom AdminSites.

comment:8 by Tim Graham <timograham@…>, 9 years ago

In 6d8c14621e2878ea2051ee56326c66969a1d18d0:

[1.7x.] Fixed #23497 -- Made admin system checks run for custom AdminSites.

Backport of b7219c7ba5fdfbf9349948b5a91af50e32822ee6 from master

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