[Django] #35418: ValueError: site must subclass AdminSite

55 views
Skip to first unread message

Django

unread,
Apr 30, 2024, 12:22:08 PM4/30/24
to django-...@googlegroups.com
#35418: ValueError: site must subclass AdminSite
-----------------------------------------+------------------------
Reporter: Lily Foote | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 5.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
In https://code.djangoproject.com/ticket/28358#comment:13 it was reported
that running tests with Django, PyPy and Coverage would fail with a
{{{ValueError: site must subclass AdminSite}}} exception. This can also be
triggered on CPython when running Coverage in pure python mode. There are
upstream tickets for [https://github.com/nedbat/coveragepy/issues/1382
Coverage], [https://github.com/pypy/pypy/issues/3750 PyPy] and
[https://github.com/python/cpython/issues/98148 CPython], but these are
not seeing much progress. A small change to Django to workaround this was
proposed in https://code.djangoproject.com/ticket/28358#comment:21, but
this never landed: https://github.com/django/django/pull/16541

I think we should land the workaround in Django so this isn't an issue
even if upstream never finds a fix.
--
Ticket URL: <https://code.djangoproject.com/ticket/35418>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 2, 2024, 11:05:22 AM5/2/24
to django-...@googlegroups.com
#35418: ValueError: site must subclass AdminSite
--------------------------------------+------------------------------------
Reporter: Lily Foote | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Utilities | Version: 5.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Sarah Boyce):

* component: Uncategorized => Utilities
* stage: Unreviewed => Accepted
* type: Uncategorized => Cleanup/optimization

Comment:

Hey Lily, thank you for creating this ticket and summarizing the current
situation, including the update of the PyPy bug link.
This is a tricky one - tentatively accepting to track further
investigation of a workaround. A fix in CPython or PyPy sounds preferable
and if these start progressing, this will likely be closed as a wontfix.
But discussed with Natalia, and we're happy to look at a PR proposing the
mentioned workaround (a test would also be needed, which from comments in
#28358 that may be challenging).
--
Ticket URL: <https://code.djangoproject.com/ticket/35418#comment:1>

Django

unread,
Aug 2, 2024, 11:52:08 AM8/2/24
to django-...@googlegroups.com
#35418: ValueError: site must subclass AdminSite
--------------------------------------+------------------------------------
Reporter: Lily Foote | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Utilities | Version: 5.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Comment (by Mohammad Salehi):

Hello, if you're okay with it, I would like to start working on this
ticket and submit a PR to address the issue.
--
Ticket URL: <https://code.djangoproject.com/ticket/35418#comment:2>

Django

unread,
Apr 20, 2025, 5:55:09 PM4/20/25
to django-...@googlegroups.com
#35418: ValueError: site must subclass AdminSite
-------------------------------------+-------------------------------------
Reporter: Lily Foote | Owner: Ahmed
Type: | Nassar
Cleanup/optimization | Status: assigned
Component: Utilities | Version: 5.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ahmed Nassar):

* owner: nobody => Ahmed Nassar
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/35418#comment:3>

Django

unread,
Nov 27, 2025, 6:39:42 AM11/27/25
to django-...@googlegroups.com
#35418: ValueError: site must subclass AdminSite
-------------------------------------+-------------------------------------
Reporter: Lily Foote | Owner: Ahmed
Type: | Nassar
Cleanup/optimization | Status: assigned
Component: Utilities | Version: 5.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Carsten Agger):

Is there any progress on this?

I still have this problem on Django 5.2.8 with Pypy 3.10.16 / 7.3.19. The
workaround referenced above doesn't work with these versions, so right now
I'm at a loss regarding how to get Django to run with Pypy.
--
Ticket URL: <https://code.djangoproject.com/ticket/35418#comment:4>

Django

unread,
Nov 27, 2025, 7:50:42 AM11/27/25
to django-...@googlegroups.com
#35418: ValueError: site must subclass AdminSite
-------------------------------------+-------------------------------------
Reporter: Lily Foote | Owner: Ahmed
Type: | Nassar
Cleanup/optimization | Status: assigned
Component: Utilities | Version: 5.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Carsten Agger):

OK, I found a workaround which could hold during development:

{{{
--- a/django/contrib/admin/decorators.py
+++ b/django/contrib/admin/decorators.py
@@ -98,8 +98,8 @@ def register(*models, site=None):

admin_site = site or default_site

- if not isinstance(admin_site, AdminSite):
- raise ValueError("site must subclass AdminSite")
+ # if not isinstance(admin_site, AdminSite):
+ # raise ValueError("site must subclass AdminSite")

if not issubclass(admin_class, ModelAdmin):
raise ValueError("Wrapped class must subclass ModelAdmin.")

}}}

This at least makes tests pass. It remains to be seen if it actually works
in practice.
--
Ticket URL: <https://code.djangoproject.com/ticket/35418#comment:5>

Django

unread,
Nov 27, 2025, 7:51:59 AM11/27/25
to django-...@googlegroups.com
#35418: ValueError: site must subclass AdminSite
-------------------------------------+-------------------------------------
Reporter: Lily Foote | Owner: Ahmed
Type: | Nassar
Cleanup/optimization | Status: assigned
Component: Utilities | Version: 5.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Carsten Agger):

If somebody reads this and knows a genuinely good workaround (that doesn't
commenting out a check that probably should be there) I'd like to hear
about it.
--
Ticket URL: <https://code.djangoproject.com/ticket/35418#comment:6>
Reply all
Reply to author
Forward
0 new messages