2017-01-08 28 views
1

用戶點擊鏈接/登錄/蒸汽。在那之後所有的作品propetly(django.contrib.auth用戶實例和social_auth用戶實例打造精品,自定義管道工程,但之後當我嘗試登錄後使用request.user在我看來,用蒸汽我有錯誤不驗證用戶django-social-auth?

'AnonymousUser' 對象不是可迭代

我的settings.py文件

SOCIAL_AUTH_PIPELINE = (
'social.pipeline.social_auth.social_details', 
'social.pipeline.social_auth.social_uid', 
'social.pipeline.social_auth.social_user', 
# custom pipeline 
'markers.pipeline.add_steam_data_marker', 
# 
'social.pipeline.user.get_username', 
'social.pipeline.user.create_user', 
'social.pipeline.social_auth.auth_allowed', 
'social.pipeline.social_auth.associate_user', 
'social.pipeline.social_auth.load_extra_data', 
'social.pipeline.user.user_details',) 

在App我定製pipeline.py

def add_steam_data_marker(strategy, details, backend, uid, *args, **kwargs): 

if backend.name == 'steam': 
    try: 
     Model.objects.get(steam_user_id=uid) 
     return redirect('/home/') 
    except ObjectDoesNotExist: 
     Model.objects.create(
      ........, 
     ) 

     return redirect('/model/add/') 

回答

2

所有的麻煩都在AUTHENTICATION_BACKENDS中,不用用戶社交。 .....使用social_core - >'social_core.backends.steam.SteamOpenId',

+0

謝謝!!!我也是。 – user963936