• 
      

    Fix loading some parts of the Django administration UI.

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

    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.

    Summary ID
    Fix loading some parts of the Django administration UI.
    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.
    620b1fb47e30bb8ab29dc4ef00b00ff7d89c15c9
    david
    1. Ship It!
    2. 
        
    chipx86
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-4.0.x (146fbaf)