标签:dex bsp 用户 ase username request 错误 def 开发
1、基于类的方式重写登录:views.py:
from django.views.generic.base import View class LoginView(View): def get(self,request): return render(request, "test/login.html", {}) def post(self,request): user_name = request.POST.get("username", "") pass_word = request.POST.get("password", "") user = authenticate(username=user_name, password=pass_word) if user is not None: dj_login(request, user) return render(request, "test/index.html", {}) else: return render(request, "test/login.html", {"msg": "用户名或密码错误"})
users.py:
url(r‘^login/$‘, LoginView.as_view(), name="login"),
标签:dex bsp 用户 ase username request 错误 def 开发
原文地址:http://www.cnblogs.com/lanqie/p/7657560.html