【发布时间】:2013-05-10 18:45:35
【问题描述】:
我正在使用 Django 1.5 的自定义用户配置文件,并且我正在尝试使用最新的 django-registration 版本,但运行同步命令时总是出错。
CommandError: One or more models did not validate:
registration.registrationprofile: 'user' defines a relation with the model 'auth.User', which has been swapped out. Update the relation to point at settings.AUTH_USER_MODEL.
型号:
class UserProfile(AbstractBaseUser):
username = models.CharField(max_length=140)
email = models.EmailField(
verbose_name='email address',
max_length=254,
unique=True,
db_index=True,
)
设置:
AUTH_USER_MODEL = 'gofindwhat_app.UserProfile'
【问题讨论】:
-
AbstractBaseUser的定义是什么?它不能引用django.contrib.auth.User -
AbstractBaseUser 是 Django 1.5 中的新成员,是 django.contrib.auth.models 的一部分。
-
我找到了解决这个问题的方法,方法是对 django-registration 进行一些更改...但我真的不想这样做。
-
请告诉我,你是怎么解决这个问题的?
标签: python django django-registration