python-social-auth
私はで仕事をしようとしmongodb
ます。
ここに追加するように指示されている指示に従います。
INSTALLED_APPS = (
...
'social.apps.django_app.me',
...
)
と
SOCIAL_AUTH_STORAGE = 'social.apps.django_app.me.models.DjangoStorage'
ただし、何か問題が発生し、ImportError が発生します。
Unhandled exception in thread started by <bound method Command.inner_run of <django.contrib.staticfiles.management.commands.runserver.Command object at 0x101c51d50>>
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 92, in inner_run
self.validate(display_num_errors=True)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 280, in validate
num_errors = get_validation_errors(s, app)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/validation.py", line 35, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/loading.py", line 166, in get_app_errors
self._populate()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/loading.py", line 75, in _populate
self.load_app(app_name)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/models/loading.py", line 96, in load_app
models = import_module('.models', app_name)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/social/apps/django_app/me/models.py", line 29, in <module>
'mongoengine.django.auth.User'
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/social/utils.py", line 21, in module_member
module = import_module(mod)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/social/utils.py", line 15, in import_module
__import__(name)
ImportError: No module named auth
私のsettings.pyにも次のコードがあります。コメントアウトする'social.apps.django_app.me',
と、ソーシャル認証に接続されたデータベースがなくなります。そのままにしておくと、コードは失敗します。
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'mongoengine.django.mongo_auth',
'social.apps.django_app.default',
'social.apps.django_app.me', # this is the line that fails
)
AUTHENTICATION_BACKENDS = (
'mongoengine.django.auth.MongoEngineBackend',
'django.contrib.auth.backends.ModelBackend',
'social.backends.facebook.FacebookOAuth2',
)
# Engine stuff
SESSION_ENGINE = 'mongoengine.django.sessions'
#AUTH_USER_MODEL = 'mongo_auth.MongoUser'
MONGOENGINE_USER_DOCUMENT = 'mongoengine.django.auth.User'
_MONGODB_USER = '***' #real stuf here
_MONGODB_PASSWD = '***' #real stuf here
_MONGODB_HOST = '***' #real stuf here
_MONGODB_NAME = '****' #real stuf here
_MONGODB_DATABASE_HOST = \
'mongodb://%s:%s@%s/%s' \
% (_MONGODB_USER, _MONGODB_PASSWD, _MONGODB_HOST, _MONGODB_NAME)
mongoengine.connect(_MONGODB_NAME, host=_MONGODB_DATABASE_HOST)
# Auth Stuff
SOCIAL_AUTH_STORAGE = 'social.apps.django_app.me.models.DjangoStorage'
SOCIAL_AUTH_FACEBOOK_KEY = '***' #real stuf here
SOCIAL_AUTH_FACEBOOK_SECRET = '***' #real stuf here
SOCIAL_AUTH_FACEBOOK_SCOPE = ['email','user_location']
追加するものがありませんか?どうすれば修正できますか?