我正在使用自定义用户模型,使用AbstractUser进行扩展.这是我的models.py:
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models
from django.contrib.auth.models import AbstractUser
from django.contrib.auth.forms import UserCreationForm
from django import forms
# Create your models here.
class User(AbstractUser):
pass
class SignUpForm(UserCreationForm):
first_name = forms.CharField(max_length=30, required=False, help_text='Optional.')
last_name = forms.CharField(max_length=30, required=False, help_text='Optional.')
email = forms.EmailField(max_length=254, help_text='Required. Inform a valid email address.')
class Meta:
model = User
fields = ('username', 'first_name', 'last_name', 'email', 'password1', 'password2', )
enter code here
Run Code Online (Sandbox Code Playgroud)
因此,当我尝试运行开发服务器或迁移数据库时,它会返回以下错误:
Traceback (most recent call last):
File "./manage.py", …Run Code Online (Sandbox Code Playgroud)