【问题标题】:An error while migrating -"no module named 'social_django'."迁移时出错 -“没有名为 'social_django' 的模块。”
【发布时间】:2017-08-18 06:26:02
【问题描述】:

我已经安装了python-social-auth==0.3.6。然后我迁移了,报错:

from social_django.models import AbstractUserSocialAuth, UserSocialAuth, Nonce, Association, Code, DjangoStorage
ImportError: No module named 'social_django'

【问题讨论】:

  • 我也安装了:pip install python-social-auth[django] 和 pip install social-auth-app-django。但同样的错误发生。 Django 版本 ==1.10.5
  • 如果你 pip freeze 你会得到什么?
  • (书签) C:\Python34>pip freeze defusedxml==0.5.0 Django==1.10.6 django-allauth==0.31.0 oauthlib==2.0.2 Pillow==2.9.0 PyJWT==1.4.2 python-social-auth==0.3.6 python3-openid==3.1.0 requests==2.13.0 requests-oauthlib==0.8.0 六==1.10.0 social-auth-app- django==1.1.0 social-auth-core==1.2.0
  • 这很奇怪。我有完全相同的 virtualenv 并且工作出色,没有错误。你是否真的在你的项目中使用过这个包?
  • 其实我告诉我我是初学者。所以我在这本书的帮助下做这个项目。我有很多问题,我都解决了,但这对我来说真的很难。关于包-可以指定哪个包请

标签: django


【解决方案1】:

[更新]:对我有用的是:

  1. 在一个干净的 virtualenv I pip install python-social-auth[django]
  2. 我将'django_social', 包含在我的INSTALLED_APPS
  3. 我运行迁移,./manage.py migrate

你需要安装python-social-auth[django]:

pip install python-social-auth[django]

然后将'social.apps.django_app.default' 添加到您的INSTALLED_APPS

然后别忘了运行迁移:./manage.py migrate

【讨论】:

  • ISTALLED_APPS:INSTALLED_APPS = ['account', 'images', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib. session','django.contrib.messages','django.contrib.staticfiles','social.apps.django_app.default',但同样的错误
  • AUTHENTICATION_BACKENDS:AUTHENTICATION_BACKENDS = ('social.backends.facebook.Facebook2OAuth2', 'social.backends.google.GoogleOAuth2', 'social.backends.twitter.TwitterOAuth', 'django.contrib.auth. backends.ModelBackend','account.authentication.EmailAuthBackend',
  • pip install social-auth-app-django了吗?
  • 是的,我已经安装了 pip install social-auth-app-django
  • 你安装了Django,不是吗? pip install Django
【解决方案2】:

我解决了

pip install django-rest-framework-social-oauth2==1.0.4 social-auth-core==0.2.1 python-social-auth==0.2.21 django-oauth-toolkit==0.10.0

【讨论】:

    猜你喜欢
    • 2018-03-19
    • 2017-09-17
    • 2021-12-31
    • 2020-02-27
    • 1970-01-01
    • 2021-03-14
    • 2015-08-22
    • 2017-01-27
    • 2014-11-12
    相关资源
    最近更新 更多