Remove default apps from Django-admin


Question

By default, in Django-admin there is Users, Groups, and Sites apps. How can I remove Groups and Sites?

I tried to remove admin.autodiscover() from root urls. Then, when I added something like admin.site.register(User, UserAdmin) somewhere in my app models I got an AlreadyRegistered exception (this is fairly right - models users already registered in django.contrib.auth).

1
48
9/10/2014 9:40:02 PM

Accepted Answer

In an admin.py you know will definitely be loaded, try:

admin.site.unregister(User)
admin.site.unregister(Group)
admin.site.unregister(Site)
91
2/26/2010 2:10:13 PM

In addition to the above double check your ordering of "INSTALLED_APPS" in "settings.py"

INSTALLED_APPS = [
    # django apps first
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

    # custom apps below
    'my_app'
]

Otherwise it will cause an error. See here: Issue with Django admin registering an inline user profile admin


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon