从Django-Social-auth到Python-Social-auth,用于现场用户冲突的访问者



我正在移植一个项目,从使用django-social-auth到python-social-auth。我遵循文档中的说明,但是当我尝试运行项目测试(./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迁移正常,正如预期的那样,因为(如文档所述),python-social-auth中的模型表名称被定义为与Django-Social上使用的模型兼容-auth,因此不需要迁移数据。

遇到了同一问题。

即使从installed_apps中删除了django-social-auth库,但django仍在发现冲突,因为django-social-auth和python-social-auth都使用具有相同相关的classe_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将其从站点包装中删除,但也要记住从Easy_install.pth.pth

中删除该名称。

您也可以使用PIP卸载

希望这会有所帮助。

最新更新