from django.contrib import admin from django.contrib.auth.admin import UserAdmin from .models import CustomUser class CustomUserAdmin(UserAdmin): model = CustomUser list_display = ("id", "full_name", "role", "is_active") readonly_fields = ("date_joined",) # Add this line to include the role field in the admin form fieldsets = UserAdmin.fieldsets + \ ((None, {"fields": ("role", "sex", "birthday")}),) admin.site.register(CustomUser, CustomUserAdmin)