Search code examples
django-adminwagtailmodeladmin

How do you unregister a model in wagtail modeladmin?


I need to do the equivalent of... 'admin.site.unregister(Value)' but for a model registered with wagtailmodeladmin using 'modeladmin_register(Value)' in wagtail_hooks.py. How do you do that?


Solution

  • I know this is an old question, but the short answer is "There is no unregister equivalent".

    In standard Django, all the models you see in Django's admin area have been registered in a similar fashion, so unregister makes sense there. In Wagtail, the admin area is completely custom, and 'modeladmin' isn't central to the admin architecture like Django's similar solution is. The various apps within Wagtail do not use import/use it to register their own models. Therefore, there is no way to 'unregister' any of those apps using modeladmin. The 'modeladmin' app is just a utility thing to help you add interfaces for additional models without having to understand all of the various hooks provided by wagtail to do such things.

    So, with 'modeladmin' only being used to register custom models, the need for an 'unregister' method is greatly reduced, because in most cases, you'll be in control of what models you are registering via the modeladmin_register method, and so you should be able to just 'not register' those.