Skip to main content
 首页 » 编程设计

python之如何在 django-registration 中使用自定义配置文件

2024年11月01日19bjzhanghao

我正在使用 Django 1.5 的自定义用户配置文件,我正在尝试使用最新的 django 注册版本,但在运行同步命令时我总是会出错。

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' 

请您参考如下方法:

Olga,首先我必须做这个改变: https://bitbucket.org/prjts/django-registration/commits/ba31fc3053bfca7eb7a19d912882e50e295adc55

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