-1

嗨,我正在尝试通过 facebook 登录我的网站。我正在使用 django-social-auth 。

我的设置部分是:

FACEBOOK_APP_ID = 'facebook app id here'
FACEBOOK_API_SECERET = 'api secret here'

FACEBOOK_EXTENDED_PERMISSIONS = ['email', 'user_location', 'user_photos']

AUTHENTICATION_BACKENDS = (
    'social_auth.backends.facebook.FacebookBackened',
)

LOGIN_URL = '/account/login/'
LOGIN_REDIRECT_URL = '/account/post_login/'

在网址中:

url(r'', include('social_auth.urls'))

在模板中:

<a rel="nofollow" href="{% url 'socialauth_begin' 'facebook' %}">facebook</a>

错误跟踪是这样的:

Request Method: GET
Request URL: http://127.0.0.1:8000/login/facebook/

Django Version: 1.5.1
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'grappelli',
 'django.contrib.admin',
 'south',
 'djrill',
 'bootstrapform',
 'djcelery',
 'djcelery_email',
 'social_auth',
 'smbhero',
 'apps.common',
 'apps.account',
 'apps.company',
 'apps.content')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/mnt/www/smb/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  115.                         response = callback(request, *callback_args, **callback_kwargs)
File "/mnt/www/smb/local/lib/python2.7/site-packages/social_auth/decorators.py" in wrapper
  26.                                                       redirect)
File "/mnt/www/smb/local/lib/python2.7/site-packages/social_auth/backends/__init__.py" in get_backend
  994.         get_backends(force_load=True)
File "/mnt/www/smb/local/lib/python2.7/site-packages/social_auth/backends/__init__.py" in get_backends
  971.             backend = getattr(module, cls_name)

Exception Type: AttributeError at /login/facebook/
Exception Value: 'module' object has no attribute 'FacebookBackened'

我做错了什么?我应该怎么做才能解决它?

4

2 回答 2

2

您拼写错误的后端 ( FacebookBackened)。将其更改为:

    'social_auth.backends.facebook.FacebookBackend',
于 2013-09-12T06:08:20.073 回答
0

确保使用以下命令安装了 python-social-auth pip install python-social-auth[django]

python-social-auth with Django: ImportError: No module named 'social_django'

然后,您可以尝试将:'social_auth.backends.facebook.FacebookBackened'替换为:'social.backends.facebook.FacebookOAuth2'

在项目的“urls.py”中尝试这个 url: url('social-auth/', include('social.apps.django_app.urls', namespace='social')

在项目的主 settings.py 文件中,确保您已将其包含在 INSTALLED_APPS 列表中,“social.apps.django_app.default”...

在收到“AttributeError at /login/facebook/‘module’对象没有属性‘FacebookBackened’”后,这对我有用

于 2018-03-13T16:41:00.233 回答