首页 > 解决方案 > 从 social.apps.django_app.views 导入命名空间

问题描述

我正在使用 Python 3.6、Django 2.0.7 和这些人做一个项目:

certifi==2018.4.16
chardet==3.0.4
defusedxml==0.5.0
dj-database-url==0.4.1
Django==2.0.7
django-bootstrap3==7.0.1
django-braces==1.13.0
django-oauth-toolkit==1.2.0
django-rest-framework-social-oauth2==1.0.4
djangorestframework==3.8.2
gunicorn==19.6.0
idna==2.7
oauthlib==2.1.0
Pillow==5.1.0
psycopg2==2.7.1
PyJWT==1.6.4
python-social-auth==0.3.6
python3-openid==3.1.0
pytz==2018.5
requests==2.19.1
requests-oauthlib==1.0.0
six==1.11.0
social-auth-app-django==1.1.0
social-auth-core==1.7.0
urllib3==1.23
whitenoise==3.2.1

这是我收到的错误消息:

from .oauth2_grants import SocialTokenGrant
  File "/Users/user/Desktop/myvirtualenv/foodtasker/lib/python3.6/site-packages/rest_framework_social_oauth2/oauth2_grants.py", line 13, in <module>
    from social.apps.django_app.views import NAMESPACE

ImportError: cannot import name 'NAMESPACE'

问题是我如何解决这个问题以及我可以在哪里导入 NAMESPACE。

标签: pythondjangoatom-editor

解决方案


Django OAuth Toolkit 还不支持 Django 2.x。从文档

要求

  • Python 2.7、3.4、3.5、3.6
  • Django 1.8、1.9、1.10、1.11

您可以将 Django 安装降级到 1.11,以便能够使用 Django OAuth Toolkit 和 django-rest-framework-social-oauth2。


推荐阅读