📜  在 ModelAdmin 中添加带有字段集的新字段以编辑用户,并在创建新用户时添加_fieldsets - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:31.051000             🧑  作者: Mango

代码示例1
from django.contrib.auth.admin import UserAdmin

class CustomUserAdmin(UserAdmin):
    ...
    fieldsets = UserAdmin.fieldsets + (
        (None, {'fields': ('custom_field',)}),
    )
    add_fieldsets = UserAdmin.add_fieldsets + (
        (None, {'fields': ('custom_field',)}),
    )