帮我写一个django的登陆验证
时间: 2023-03-01 18:17:46 浏览: 102
django 简单实现登录验证给你
我可以为你提供一个基于Django的登录验证示例: from django.contrib.auth import authenticate, logindef login_user(request):
username = request.POST['username']
password = request.POST['password']
user = authenticate(request, username=username, password=password)
if user is not None:
login(request, user)
return redirect('home')
else:
return redirect('login')
阅读全文