解决方案
models.py
class User(AbstractUser): roles = models.ManyToManyField("Role")
admin.py
from django.contrib.auth.admin import UserAdmin #使用django自己的UserAdmin来注册from django.utils.translation import gettext, gettext_lazy as _from .models import Userclass UserAdmin(UserAdmin): #重写fieldsets在admin后台加入自己新增的字段 fieldsets = ( (None, {'fields': ('username', 'password')}), (_('Personal info'), {'fields': ('first_name', 'last_name', 'email')}), (_('Permissions'), {'fields': ('is_active', 'is_staff', 'is_superuser', 'groups', 'user_permissions')}), (_('Important dates'), {'fields': ('last_login', 'date_joined')}), (_('Roles'), {'fields': ('roles',)}), )admin.site.register(User, UserAdmin)