[Fixed]-How to move model to the other section in Django's site admin

17👍

Is it possible to move default Groups model from ‘Authentication and Authoriation’ section (on the Django admin site) to custom one and how to achieve that?

Yes, it’s possible.

1) You can move your model to section auth, just add to your class:

class Meta:
    app_label = 'auth'

2) You can move Group and User models to your app section, for that variant need to:

Override user model and add it to your app

from django.contrib.auth.models import AbstractUser


class CustomUser(AbstractUser):
    pass

also need add to your project settings AUTH_USER_MODEL = 'your_app.CustomUser'

Don’t forget declare in admin.py from your app:

class UserAdmin(admin.ModelAdmin):
    pass


admin.site.register(CustomUser, UserAdmin)

For group model put this code in admin.py:

from django.db.models.loading import get_models
from django.contrib.auth import models

models = get_models(models)
models[1]._meta.app_label = 'your_app'

3) You can look at django-admin-tools

Leave a comment