我创建了一个自定义用户模型,这是我的模型。
from django.contrib.auth.models import AbstractUser
from django.db import models
class CustomUser(AbstractUser):
# add additional fields in here
role = models.CharField(max_length=100)
def __str__(self):
return self.email
这是admin.py:
from django.contrib import admin
from django.contrib.auth import get_user_model
from django.contrib.auth.admin import UserAdmin
from .form import CustomUserCreationForm, CustomUserChangeForm
from .models import CustomUser
class CustomUserAdmin(UserAdmin):
add_form = CustomUserCreationForm
form = CustomUserChangeForm
model = CustomUser
list_display = ['email', 'username',]
admin.site.register(CustomUser, CustomUserAdmin)
现在,当我尝试从管理页面创建新用户时,出现以下错误:NotImplementedError在/ admin / account / customuser / add /尚未为SQL SAVEPOINT“ s8052_x1”实现的UNKNOWN命令