Opened 19 months ago
Last modified 3 days ago
#35418 assigned Cleanup/optimization
ValueError: site must subclass AdminSite
| Reported by: | Lily Foote | Owned by: | Ahmed Nassar |
|---|---|---|---|
| Component: | Utilities | Version: | 5.0 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
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 Coverage, PyPy and 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.
Change History (6)
comment:1 by , 19 months ago
| Component: | Uncategorized → Utilities |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
| Type: | Uncategorized → Cleanup/optimization |
comment:2 by , 16 months ago
Hello, if you're okay with it, I would like to start working on this ticket and submit a PR to address the issue.
comment:3 by , 7 months ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:4 by , 3 days ago
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.
comment:5 by , 3 days ago
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.
comment:6 by , 3 days ago
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.
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).