gpt4 book ai didi

python - Django allauth 没有检测到 user.is_authenticated

转载 作者:行者123 更新时间:2023-12-05 07:55:20 25 4
gpt4 key购买 nike

我刚刚安装了 django all-auth 模块,我的问题是用户 session 始终为 falseuser.is_authenticated 总是给我 false。我注册并使用我的凭据登录,然后被重定向到 REDIRECT_URL。如果我现在转到 accounts/login 页面,我将再次被重定向到 REDIRECT_URL。直到我使用 accounts/logout 注销。所以我实际上已经登录了,但是 user.is_authenticated 不工作。感谢您的帮助。

我有这个简单的代码:

 {% if user.is_authenticated %}
Welcome back {{ user.email }}
{% else %}
You are not logged in
{% endif %}

Settings.py(allauth 设置):

ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_UNIQUE_EMAIL = True
#ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
ACCOUNT_EMAIL_VERIFICATION = ("none")
ACCOUNT_USERNAME_REQUIRED = False
ACCOUNT_AUTHENTICATION_METHOD = 'email'
LOGIN_REDIRECT_URL = 'http://localhost:8000/app/'
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

最佳答案

问题是,我没有使用包含 requestContext 参数的 render 函数,我丢失了。现在一切正常。非常感谢您的支持。

关于python - Django allauth 没有检测到 user.is_authenticated,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29898680/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com