我正在尝试使用 django-social-auth 在我的应用程序中实现 google openid 登录,我的问题是我收到此错误:
TemplateSyntaxError at /login
Caught ImportError while rendering: cannot import name get_backend
Request Method: GET
Request URL: #############################
Django Version: 1.3.1
Exception Type: TemplateSyntaxError
Exception Value:
Caught ImportError while rendering: cannot import name get_backend
Exception Location: /home/group018/web/WSProject/social_auth/views.py in <module>, line 19
Python Executable: /usr/bin/python2.7
Python Version:
在异常位置,您可以看到我的项目的层次结构。
该view.py
文件如下:
from functools import wraps
from django.http import HttpResponseRedirect, HttpResponse,HttpResponseServerError
from django.core.urlresolvers import reverse
from django.contrib.auth import login, REDIRECT_FIELD_NAME
from django.contrib.auth.decorators import login_required
from django.contrib import messages
from django.utils.importlib import import_module
from django.views.decorators.csrf import csrf_exempt
from WSProject.social_auth.utils import sanitize_redirect, setting, log,backend_setting, clean_partial_pipeline
from WSProject.social_auth.backends import get_backend
DEFAULT_REDIRECT = setting('SOCIAL_AUTH_LOGIN_REDIRECT_URL') or setting('LOGIN_REDIRECT_URL')
LOGIN_ERROR_URL = setting('LOGIN_ERROR_URL', setting('LOGIN_URL'))
RAISE_EXCEPTIONS = setting('SOCIAL_AUTH_RAISE_EXCEPTIONS', setting('DEBUG'))
PROCESS_EXCEPTIONS = setting('SOCIAL_AUTH_PROCESS_EXCEPTIONS','social_auth.utils.log_exceptions_to_messages')
def dsa_view(redirect_name=None):
.
.
.
函数 get_backend 在中定义WSProject/social_auth/backends/__init__.py
,我尝试将其导入为:
from WSProject.social_auth.backends.__init__ import get_backend
但它不起作用......有什么想法吗?
请注意,下面的导入到我说的那个是有效的
已解决:最后我做到了,问题出在库上,正如 jpic 所说,它们没有正确安装。