Fix loading some parts of the Django administration UI.
Review Request #11612 — Created May 21, 2021 and submitted — Latest diff uploaded
Review Board 4.0 introduced its own
AdminSiteclass, 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 (sinceAdminSitekeeps them
around), but it turns out thatadmin.pydiscovery would copy and reset
the instance any time anadmin.pywas missing from a module. That
broke our shared instances, meaning that we could only share up to the
first module missing anadmin.py.We now copy state, rather than attempting to share state, and override
theAdminSiteinstance indjango.contrib.admin. This isn't ideal,
but Django, despite supporting customAdminSitesubclasses, 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.