从django-social-auth移植到python-social-auth时,现场用户冲突的访问者

时间:2014-01-22 20:20:37

标签: python django authentication django-socialauth python-social-auth

我正在将项目从使用django-social-auth移植到python-social-auth。我按照文档中的instructions进行了操作,但是当我尝试运行项目的测试(./manage.py测试)时,我收到以下错误:

Creating test database for alias 'default' ...
CommandError: One or more models did not validate:
default.usersocialauth: Accessor for field 'user' clashes with related field 'User.social_auth'. Add a related_name argument to the definition for 'user'.
default.usersocialauth: Reverse query name for field 'user' clashes with related field 'User.social_auth'. Add a related_name argument to the definition for 'user'.

./ manage.py syncdb和./manage migrate正常工作,正如预期的那样,因为(如文档所述),python-social-auth中的模型表名称被定义为与django-social上使用的那些兼容-auth,因此不需要迁移数据。

1 个答案:

答案 0 :(得分:4)

遇到同样的问题。

尽管django-social-auth库已从INSTALLED_APPS中删除,但django仍然发现冲突,因为django-social-auth和python-social-auth都使用相同的外键和相同的related_name参数。

要确切知道python-social-auth与之冲突的模型,请在

中添加断点
get_validation_errors (validation.py)

第148和150行

for r in rel_opts.get_all_related_objects():
    if r.field is not f:
        if r.get_accessor_name() == rel_name:
            e.add(opts, "Accessor for field '%s' clashes with related field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))
        if r.get_accessor_name() == rel_query_name:
            e.add(opts, "Reverse query name for field '%s' clashes with related field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))

查看'r'变量将显示正在发生冲突的相关对象。

从系统中完全删除库django-social-auth解决了这个问题。

由于它最初安装了easy_install,我使用rm -rf将其从site-packages中删除,但是还记得从easy_install.pth中删除该名称

您也可以使用pip uninstall

希望这有帮助。

相关问题