#CBV #urls.py # urlpatterns = [ # url(r'^admin/', admin.site.urls), # url(r'^(?P<version>w+)/users/$', views.UsersView.as_view(),name='xxxx'), # url(r'^index/',views.IndexView.as_view()) # # ] from django.views import View # class IndexView(View): # def get(self,request,*args,**kwargs): # return render(request,'n1.html') # # def post(self,request,*args,**kwargs): # return HttpResponse("ok") #tips #1.在路由中类加上as_views()方法 #2.在写类的时候需要继承View类