Fix loading some parts of the Django administration UI.

Review Request #11612 — Created May 21, 2021 and submitted — Latest diff uploaded

Information

Review Board
release-4.0.x

Reviewers

Review Board 4.0 introduced its own AdminSite class, which attempted
to mirror the main one. This mostly worked, but some apps (namely in our
case, Django Evolution) didn't make it into our mirror.

This is because we were actually sharing instances of the dictionaries,
expecting that they wouldn't be replaced (since AdminSite keeps them
around), but it turns out that admin.py discovery would copy and reset
the instance any time an admin.py was missing from a module. That
broke our shared instances, meaning that we could only share up to the
first module missing an admin.py.

We now copy state, rather than attempting to share state, and override
the AdminSite instance in django.contrib.admin. This isn't ideal,
but Django, despite supporting custom AdminSite subclasses, doesn't
offer an alternative (at least in 1.11). This is the approach other
projects appear to have settled on.

Tested loading all parts of the admin UI (list and change forms),
without encountering any crashes.

Commits

Files

    Loading...