Keep the user and group in the same section in the Django admin panel

I created my own model Userin Django 1.8 with

from django.contrib.auth.models import AbstractUser, Group, Permission

class MyUser(AbstractUser):
    pass

But he no longer appears in the admin panel.

I tried adding it to the admin page using

from django.contrib.auth import get_user_model, models as auth_models
from django.contrib.auth.admin import UserAdmin

UserModel = get_user_model()

class MyUserAdmin(UserAdmin):
    pass

admin.site.register(UserModel, MyUserAdmin)

and now it appears in admin, but in a different "section" than Group. How to save Userin the default section of the admin panel?

+4
source share
1 answer

You need to add app_labelMeta MyUser to the class.

class MyUser(AbstractUser):
    pass
    class Meta:
        app_label = 'auth'

The official documentation for app_label .

0
source

All Articles