簡體   English   中英

從django-social-auth移植到python-social-auth時,現場用戶的訪問器發生沖突

[英]Accessor for field user clashes when porting from django-social-auth to 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 migration可以正常工作,因為(如文檔所述),python-social-auth中的模型表名稱已定義為與django-social-auth上使用的模型表兼容,因此不需要遷移數據。

遇到同樣的問題。

即使從INSTALLED_APPS中刪除了django-social-auth庫,由於django-social-auth和python-social-auth都使用具有相同related_name參數的相同外鍵,因此django仍然發現了沖突。

要確切知道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中刪除該名稱。

您還可以使用pip卸載

希望這可以幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM