我有一个小观点:
def AccountHome(request):
return render(request, 'myapp/account/accounthome.html', {
})
在以前的视图中,我使用了:
if user is not None and user.is_active
在使用本机表单类(如:AuthenticationForm
)时检查用户是否已通过身份验证,例如在登录用户时
但是在这个视图上,我没有使用它,是否有某种方法可以验证用户是否登录,而不需要再次使用这个AuthenticationForm
类again? This
视图s purpose is to show the homescreen when logged in, so it seems non-intuitive to extend that
身份验证表单`类
有什么帮助或想法吗
谢谢
使用
is_authenticated()
方法像这样:
if request.user.is_authenticated():
您可以在此处找到引用:https://docs.djangoproject.com/en/dev/ref/contrib/auth/#methods
相关问题 更多 >
编程相关推荐