Opened 6 years ago

Closed 6 years ago

Last modified 6 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:1 Changed 6 years ago by Andrew Mosson

Has patch: set

comment:2 Changed 6 years ago by Simon Charette

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

comment:3 Changed 6 years ago by Andrew Mosson

comment:4 Changed 6 years ago by Tim Graham

Triage Stage: UnreviewedAccepted

comment:5 Changed 6 years ago by Andrew Mosson

Owner: changed from nobody to Andrew Mosson
Status: newassigned

comment:6 Changed 6 years ago by Berker Peksag

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 Changed 6 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: assignedclosed

In b7219c7ba5fdfbf9349948b5a91af50e32822ee6:

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

comment:8 Changed 6 years ago by Tim Graham <timograham@…>

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