def post(self, request): form = LoginForm(request.POST) if form.is_valid(): user = authenticate( username=form.cleaned_data["username"], password=form.cleaned_data["password"], ) if user and user.is_active: login(request, user) messages.success(request, "自动跳转到用户中心", extra_tags="登录成功!") return HttpResponseRedirect(reverse("sspanel:userinfo")) else: messages.error(request, "请重新填写信息!", extra_tags="登录失败!") context = {"form": LoginForm()} return render(request, "sspanel/login.html", context=context)
def get(self, request): context = {"form": LoginForm()} return render(request, "sspanel/login.html", context=context)
def get(self, request): context = {"form": LoginForm(), "simple_extra_static": True} return render(request, "sspanel/login.html", context=context)