这是我的Django的第一个项目,我安装Django社会权威性和工作正常,但是当我使用自定义管道注册进入/登录错误管道Django的社会权威性
使用Python 2.6的Django 1.6.2
#settings.py
SOCIAL_AUTH_PIPELINE = (
'social_auth.backends.pipeline.social.social_auth_user',
'social_auth.backends.pipeline.user.create_user',
'social_auth.backends.pipeline.social.associate_user',
'social_auth.backends.pipeline.social.load_extra_data',
'social_auth.backends.pipeline.user.update_user_details',
'social_auth.backends.pipeline.misc.save_status_to_session',
'app.pipelines.get_user_avatar'
)
#pipelines.py
def get_user_avatar(strategy, user, response, is_new=False,*args,**kwargs):
url = None
if is_new and strategy.backend.name == 'facebook':
url = "http://graph.facebook.com/%s/picture?type=large" % response['id']
if url:
profile = user.get_profile()
profile.photo = url # depends on where you saved it
profile.save()
#models.py
from django.db import models
from django.contrib.auth.models import User
class Profile(models.Model):
user = models.ForeignKey(User)
points = models.IntegerField(default = 0)
photo = models.URLField()
你使用的是什么版本的python和django? 'python --version'和'django-admin.py --version' – broinjc
仅供参考,Django-social-auth现已弃用。谨慎使用它。 –
使用python 2.6 django 1.6.2 –