Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove default apps from Django-admin

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).

like image 890
Anton Koval' Avatar asked Feb 26 '10 13:02

Anton Koval'


People also ask

How can I remove extra's from Django admin panel?

Take a look at the Model Meta in the django documentation. Within a Model you can add class Meta this allows additional options for your model which handles things like singular and plural naming. Show activity on this post. inside model.py or inside your customized model file add class meta within a Model Class.

Is Django admin good for production?

Django's Admin is amazing. A built-in and fully functional interface that quickly gets in and allows data entry is priceless. Developers can focus on building additional functionality instead of creating dummy interfaces to interact with the database.

How do I unregister a Django model?

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


2 Answers

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

admin.site.unregister(User) admin.site.unregister(Group) admin.site.unregister(Site) 
like image 183
Steve Jalim Avatar answered Sep 23 '22 01:09

Steve Jalim


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

like image 41
Schmalitz Avatar answered Sep 24 '22 01:09

Schmalitz