使用Account Auth验证是否已登录

2024-10-03 02:46:41 发布

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

我有一个小观点:

def AccountHome(request):

    return render(request, 'myapp/account/accounthome.html', {
    })

在以前的视图中,我使用了:

if user is not None and user.is_active

在使用本机表单类(如:AuthenticationForm)时检查用户是否已通过身份验证,例如在登录用户时

但是在这个视图上,我没有使用它,是否有某种方法可以验证用户是否登录,而不需要再次使用这个AuthenticationFormagain? This视图s purpose is to show the homescreen when logged in, so it seems non-intuitive to extend that身份验证表单`类

有什么帮助或想法吗

谢谢


Tags: to用户身份验证视图表单returnisrequest