前提・実現したいこと
DjangoでGoogle認証を実装しようとしています。
python manage.py migrate を実行した際、次のエラーメッセージが発生しました。
エラーメッセージ
bash
1(nextone) kei@tk0007-pc2:/opt/webapps/nextone$ ./manage.py migrate 2Traceback (most recent call last): 3 File "./manage.py", line 15, in <module> 4 execute_from_command_line(sys.argv) 5 File "/home/kei/.virtualenvs/nextone/lib/python3.5/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line 6 utility.execute() 7 File "/home/kei/.virtualenvs/nextone/lib/python3.5/site-packages/django/core/management/__init__.py", line 347, in execute 8 django.setup() 9 File "/home/kei/.virtualenvs/nextone/lib/python3.5/site-packages/django/__init__.py", line 24, in setup 10 apps.populate(settings.INSTALLED_APPS) 11 File "/home/kei/.virtualenvs/nextone/lib/python3.5/site-packages/django/apps/registry.py", line 112, in populate 12 app_config.import_models() 13 File "/home/kei/.virtualenvs/nextone/lib/python3.5/site-packages/django/apps/config.py", line 198, in import_models 14 self.models_module = import_module(models_module_name) 15 File "/home/kei/.virtualenvs/nextone/lib/python3.5/importlib/__init__.py", line 126, in import_module 16 return _bootstrap._gcd_import(name[level:], package, level) 17 File "<frozen importlib._bootstrap>", line 986, in _gcd_import 18 File "<frozen importlib._bootstrap>", line 969, in _find_and_load 19 File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked 20 File "<frozen importlib._bootstrap>", line 673, in _load_unlocked 21 File "<frozen importlib._bootstrap_external>", line 665, in exec_module 22 File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed 23 File "/home/kei/.virtualenvs/nextone/lib/python3.5/site-packages/social/apps/django_app/default/models.py", line 1, in <module> 24 from social_django.models import AbstractUserSocialAuth, UserSocialAuth, Nonce, Association, Code, DjangoStorage 25ImportError: No module named 'social_django' 26
nextone/setting.py(抜粋)
python
1INSTALLED_APPS = [ 2 'django.contrib.admin', 3 'django.contrib.auth', 4 'django.contrib.contenttypes', 5 'django.contrib.sessions', 6 'django.contrib.messages', 7 'django.contrib.staticfiles', 8 'social.apps.django_app.default', 9 'auth1', #アプリ名 10] 11 12TEMPLATES = [ 13 { 14 'BACKEND': 'django.template.backends.django.DjangoTemplates', 15 'DIRS': [], 16 'APP_DIRS': True, 17 'OPTIONS': { 18 'context_processors': [ 19 'django.template.context_processors.debug', 20 'django.template.context_processors.request', 21 'django.contrib.auth.context_processors.auth', 22 'django.contrib.messages.context_processors.messages', 23 ], 24 }, 25 }, 26 27 28AUTHENTICATION_BACKENDS = ( 29 'social_core.backends.google.GoogleOAuth2' , 30 'django.contrib.auth.backends.ModelBackend', 31 ) 32 33SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = 'XXXXXXXXXXXXXXXXXXXXXXXXXX' 34SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = 'XXXXXXXXXXXXXXXXX' 35 36SOCIAL_AUTH_LOGIN_REDIRECT_URL = '/' 37SOCIAL_AUTH_LOGIN_URL = '/login/'
pip freezeの結果
certifi==2018.1.18
chardet==3.0.4
defusedxml==0.5.0
Django==2.0.2
idna==2.6
oauthlib==2.0.6
PyJWT==1.5.3
python-social-auth==0.3.6
python3-openid==3.1.0
pytz==2018.3
requests==2.18.4
requests-oauthlib==0.8.0
six==1.11.0
social-auth-core==1.7.0
urllib3==1.22
環境について
python3.5.2
pip9.0.1
ubuntu16.04 x84_64
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/02/25 12:06