2021-02-04 Django 继承 AbstractUser 之后 admin 设置

  • 密码可更改
  • 手动设置修改项
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.utils.translation import gettext_lazy
from account.models import User, Gender, Grade, Province, Company


class UserInfoAdmin(UserAdmin):
    list_display = ('username', 'email', 'nickname')
    filter_horizontal = ('groups', 'user_permissions')
    fieldsets = (
        (None, {'fields': ('username', 'nickname', 'mobile', 'email', 'grade_name', 'password')}),
        (gettext_lazy('用户信息'), {'fields': ('gender', 'icon', 'province',
                                           'company_name', 'title', 'contact', 'section',
                                           'is_adult_hospital', 'is_signed', 'can_ocr', 'trans_union')}),
        (gettext_lazy('Permissions'), {'fields': ('is_superuser', 'is_staff', 'is_active',
                                                  'groups', 'user_permissions')}),
        # (gettext_lazy('Important dates'), {'fields': ('last_login', 'date_joined')}),
    )

admin.site.register(User, UserInfoAdmin)

你可能感兴趣的:(2021-02-04 Django 继承 AbstractUser 之后 admin 设置)