You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
927 B
21 lines
927 B
from django.contrib import admin
|
|
from django.contrib.auth.admin import UserAdmin
|
|
from .models import CustomUser
|
|
|
|
# HJJ: 使用装饰器注册CustomUser模型到Django管理后台
|
|
@admin.register(CustomUser)
|
|
class CustomUserAdmin(UserAdmin):
|
|
# HJJ: 指定管理的模型为CustomUser
|
|
model = CustomUser
|
|
# HJJ: 定义管理后台列表页显示的字段
|
|
list_display = ['username', 'email', 'is_staff', 'date_joined']
|
|
# HJJ: 定义管理后台可用的过滤器
|
|
list_filter = ['is_staff', 'is_active', 'date_joined']
|
|
# HJJ: 在原有字段集基础上添加扩展信息字段集
|
|
fieldsets = UserAdmin.fieldsets + (
|
|
('扩展信息', {'fields': ('bio', 'avatar', 'location', 'website')}),
|
|
)
|
|
# HJJ: 在添加用户表单中添加扩展信息字段集
|
|
add_fieldsets = UserAdmin.add_fieldsets + (
|
|
('扩展信息', {'fields': ('bio', 'avatar', 'location', 'website')}),
|
|
) |