python - 从 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。
解决方案
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。
推荐阅读
- arrays - 基于连续元素对的属性消除数组行
- sql - Postgres SQL regexp_replace 替换所有数字
- android - Android Pixel 4a 扭曲的启动图像
- javascript - 为什么我的axios post 函数总是返回401?
- python - 无法下载 ipynb 文件
- php - Laravel 中的非模型逻辑在哪里
- mongodb - 如何使用带有 $lookup 的 MongoDB 聚合来用整个文档替换包含 id 的属性?
- html - macOS 上的透明轮廓不透明?
- flutter - Dart:为什么我们在使用泛型时只声明一种类型?
- c++ - 编译器找不到 jpeg 和 png 库