CBV的写法:
from django.views import View class Home(View): def dispatch(self,request,*args,**kwargs): print 'before' result=super(Home,self).dispatch(request,*args,**kwargs) print 'after' return result def get(self,request): print request.method return render(request,"home.html") def post(self,request): print request.method return render(request, "home.html")
url(r'^home/', views.Home.as_view()),