0

这是我的项目目录:

/handshakeapp:
    templates/
    __init__.py
    admin.py
    models.py
    pipelines.py
    views.py
/VKHandshake:
    __init__.py
    settings.py
    urls.py
    ...
manage.py

这是一部分settings.py

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.social_auth.associate_user',
    'social.pipeline.social_auth.load_extra_data',
    'social.pipeline.user.user_details',
    'handshakeapp.pipelines.fill_extendeduser'
)

这是handshakeapp/pipelines.py

from models import ExtendedUser

def fill_extendeduser(strategy, details, user=None, is_new=False, *args, **kwargs):
    if user and is_new:
        user.extendeduser_set.create(user=user.get_username(), countingID=None, profilePic='http://localhost:8000/pic.png')

但它会重定向到/accounts/login/每次我尝试使用社交身份验证登录时。如果我'handshakeapp.pipelines.fill_extendeduser'从 SOCIAL_AUTH_PIPELINE 中删除,它会起作用。怎么了?

4

1 回答 1

1

问题出在fill_extendeduser功能上。它引发了一个异常,正如@omab 所提到的:

Django auth 进程将吃掉异常并重定向到 LOGIN_URL 的值,默认情况下是 /accounts/login/。因此,在您的代码周围添加一个 try/except 块以检查它是否引发任何错误。

于 2014-10-23T17:18:25.720 回答