Python社交身份验证登录(decorator中出错)

Python社交身份验证登录(decorator中出错),python,django,python-social-auth,django-socialauth,Python,Django,Python Social Auth,Django Socialauth,我对django social auth有问题。 我不知道该怎么办。当我点击ref时,我从社交网络获得了所有信息(如果我在函数login_vk中写了这个参数,我会做出回应)。请求中有 <QueryDict: {u'state': [u'5v7znP0lBNmp33V2TCOSshU4mQe4MlDn'], u'code': [u'a6acfde533fbd83437'], u'redirect_state': [u'5v7znP0lBNmp12V2TCOSshU4mQe4MlDn']}&g

我对django social auth有问题。 我不知道该怎么办。当我点击ref时,我从社交网络获得了所有信息(如果我在函数login_vk中写了这个参数,我会做出回应)。请求中有

<QueryDict: {u'state': [u'5v7znP0lBNmp33V2TCOSshU4mQe4MlDn'], u'code': [u'a6acfde533fbd83437'], u'redirect_state': [u'5v7znP0lBNmp12V2TCOSshU4mQe4MlDn']}>
但是我得到了这个错误

       Exception Value: 
'QueryDict' object has no attribute 'session'
Exception Location: /usr/local/lib/python2.7/dist-packages/social/strategies/django_strategy.py in __init__, line 30
我如何解决这个问题


设置.py

INSTALLED_APPS = ('social.apps.django_app.default',)
SOCIAL_AUTH_VK_OAUTH2_KEY = 'xxx'
SOCIAL_AUTH_VK_OAUTH2_SECRET = 'xxx'
SOCIAL_AUTH_LOGIN_URL = '/app/oauth2login'  # url for callback
#SOCIAL_AUTH_USER_MODEL = 'polls.models.MyUser'  # custom user
SOCIAL_AUTH_UID_LENGTH = 223
SOCIAL_AUTH_STRATEGY = 'social.strategies.django_strategy.DjangoStrategy'
SOCIAL_AUTH_STORAGE = 'social.apps.django_app.default.models.DjangoStorage'
SOCIAL_AUTH_PIPELINE = (
    'social.pipeline.social_auth.social_details',
    'social.pipeline.social_auth.social_uid',
    'social.pipeline.social_auth.auth_allowed',
    'social.pipeline.social_auth.social_user',
    'social.pipeline.user.get_username',
    'polls.views.login_vk',  # method wich works with social network
    'social.pipeline.social_auth.associate_user',
    'social.pipeline.social_auth.load_extra_data',
    'social.pipeline.user.user_details',
)

#  'social.apps.django_app.default', into INSTALLED_APPS

AUTHENTICATION_BACKENDS = (
    'social.backends.vk.VKOAuth2',  # and other
    #   setups and becks https://python-social-auth.readthedocs.org/en/latest/backends/index.html
    'django.contrib.auth.backends.ModelBackend',
)

url.py


模板



只要我看到django social auth已被弃用,您就需要首先切换到python social auth。@vanadium23,我已经在使用它了,所以我编辑了我的views.py并出现了一个新错误。看看我的帖子,我也编辑了它我不清楚的是:你们已经定义了view/app/oauth2login,并没有在模板中使用它。为什么你需要新的视角?
INSTALLED_APPS = ('social.apps.django_app.default',)
SOCIAL_AUTH_VK_OAUTH2_KEY = 'xxx'
SOCIAL_AUTH_VK_OAUTH2_SECRET = 'xxx'
SOCIAL_AUTH_LOGIN_URL = '/app/oauth2login'  # url for callback
#SOCIAL_AUTH_USER_MODEL = 'polls.models.MyUser'  # custom user
SOCIAL_AUTH_UID_LENGTH = 223
SOCIAL_AUTH_STRATEGY = 'social.strategies.django_strategy.DjangoStrategy'
SOCIAL_AUTH_STORAGE = 'social.apps.django_app.default.models.DjangoStorage'
SOCIAL_AUTH_PIPELINE = (
    'social.pipeline.social_auth.social_details',
    'social.pipeline.social_auth.social_uid',
    'social.pipeline.social_auth.auth_allowed',
    'social.pipeline.social_auth.social_user',
    'social.pipeline.user.get_username',
    'polls.views.login_vk',  # method wich works with social network
    'social.pipeline.social_auth.associate_user',
    'social.pipeline.social_auth.load_extra_data',
    'social.pipeline.user.user_details',
)

#  'social.apps.django_app.default', into INSTALLED_APPS

AUTHENTICATION_BACKENDS = (
    'social.backends.vk.VKOAuth2',  # and other
    #   setups and becks https://python-social-auth.readthedocs.org/en/latest/backends/index.html
    'django.contrib.auth.backends.ModelBackend',
)
 url(r'^app/', include('social.apps.django_app.urls', namespace='social')),
 url(r'^app/oauth2login$', views.oauth2login_view),  # views for auth
<a href="http://nochgames.ru/app/login/vk-oauth2/" target="blank">Login with VK</a>