[英]Keep User and Group in same section in Django admin panel
I have made my own User
model in Django 1.8 with 我在Django 1.8中制作了自己的
User
模型
from django.contrib.auth.models import AbstractUser, Group, Permission
class MyUser(AbstractUser):
pass
But it does not figure in admin any longer. 但它不再在管理员中出现。
I have tried adding it to the admin page with 我尝试将其添加到管理页面
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 it does figure in admin now but in a different 'section' than Group
. 并且它在管理人物,但现在比一个不同的“部分”
Group
。 How can I keep User
in the default section in the admin panel? 如何将
User
保留在管理面板的默认部分?
You need to add app_label
to Meta class of MyUser. 您需要将
app_label
添加到app_label
的Meta类。
class MyUser(AbstractUser):
pass
class Meta:
app_label = 'auth'
Official documentation on app_label . 有关app_label的官方文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.