urls.pyhtml
url(r'^login/', views.Login.as_view()), #类名.as_view()
views.py:python
from django.views import View class Login(View): def get(self, request): #方法里必须有request来接受传过来的值否则会报错 return render(request, "login.html") def post(self, request): pass
当请求过来的时候, 会优先判断你的请求方法是GET仍是POST, 若是是GET请求的话, 走GET函数, 反之, 走POSt函数ajax
继承View类的时候会自动对传过来的参数进行判断django
注意:函数