【问题标题】:how to use custom profiles with django-registration如何在 django-registration 中使用自定义配置文件
【发布时间】: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


【解决方案1】:

Olga,第一次我不得不做这个改变: https://bitbucket.org/prjts/django-registration/commits/ba31fc3053bfca7eb7a19d912882e50e295adc55

第二,我必须根据默认后端创建自己的后端。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-08-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-31
    • 2013-05-05
    • 2011-06-23
    • 1970-01-01
    相关资源
    最近更新 更多