类模型写views,免去了函数模式的判断
1.函数写views,如:
def xxx(request):
if request.method == "POST":
...
elif request.method == "GET":
...
2.class写views
1)views.py
from django.view.generic import View
class xxx(View) #继承了View类
def get(self,request):
...
def post(self,request):
...
2)urls.py调用views里对应的类