Opened 8 years ago

Closed 8 years ago

#18211 closed New feature (wontfix)

Add a signal to notifying when a ModelAdmin has been registered with an AdminSite

Reported by: filip.dupanovic@… Owned by: nobody
Component: contrib.admin Version:
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


When your trying to unregister a ModelAdmin instance from a particular AdminSite, it's possible that at the point of time the statement is being executed the ModelAdmin hasn't been registered and you'll get an unhandled exception.

The only way to resolve this is to rearrange the INSTALLED_APPS to make sure the particular application's modules are being imported after the ModelAdmin has been registered. If we can latch onto a signal that will notify us when a site instance has had a ModelAdmin registered, we'd have a more elegant approach to unregistering model administration we don't want to appear on the admin site.

Change History (2)

comment:1 Changed 8 years ago by Keryn Knight <django@…>

Are you able to provide a concrete example of how this would be beneficial, or fix problems you're running into that aren't solved by catching AlreadyRegistered/NotRegistered and taking the appropriate action; eg:

    # [...]
except NotRegistered:
    # Or do some other things, and then register a new ModelAdmin, MyAdmin)

comment:2 Changed 8 years ago by Julien Phalip

Resolution: wontfix
Status: newclosed

I agree with Keryn that catching the NotRegistered or AlreadyRegistered exceptions seem like the best approach here. Please feel free to reopen if you have a use case where catching those exceptions wouldn't help.

Note: See TracTickets for help on using tickets.
Back to Top