Django和PythonSocialAuth重定向(如果我生成自定义pipelin)

2024-10-01 22:36:02 发布

您现在位置:Python中文网/ 问答频道 /正文

这是我的项目目录:

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

这是settings.py的一部分

^{pr2}$

这是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')

但每次我尝试使用Social Auth登录时,它都会重定向到/accounts/login/。如果我从社交认证管道中删除'handshakeapp.pipelines.fill_extendeduser',它就会起作用。怎么了?在


Tags: 项目py目录nonenewsettingsinitis
1条回答
网友
1楼 · 发布于 2024-10-01 22:36:02

问题出在fill_extendeduser函数中。它引发了一个例外,正如@omab所说:

Django auth process will eat the exceptions and redirect to the value of LOGIN_URL which by default is /accounts/login/. So, add a try/except block around your code to check if it's raising any error.

相关问题 更多 >

    热门问题