How to unregister table from django admin whose created when package are installed

Viewed 1581

I want to remove some table or section form my django admin.

for example: i install summernote package who created attachment table in my admin. i dont want to show this table in admin (see in below screenshot)

enter image description here

2 Answers

You can unregister default models in admin.py of your app by using unregister.

from django.contrib import admin
from django_summernote.models import Attachment

admin.site.unregister(Attachment)

In your settings.py, change the INSTALLED_APPS structure something as below,

INSTALLED_APPS = [
    'django_summernote',  # this is the third-party app
    'my_django_app',  # this is your app
    ...
]

Then, in the admin.py of my_django_app

from django_summernote.models import Attachment
admin.site.unregister(Attachment)

The order of INSTALLED_APPS structure is important here. Because, Django loads each apps according to the order in which we put those in the INSTALLED_APPS.

Related