FBV与CBV

# 视图函数既可以是函数也可以是类
函数FBV 类CBV

def index(request):
  return HttpResponse('index')

# CBV
    # CBV路由
    url(r'^login/',views.MyLogin.as_view())


  from django.views import View


  class MyLogin(View):
     def get(self,request):
        return render(request,'form.html')

     def post(self,request):
        return HttpResponse('post方法')
      
"""
FBV和CBV各有千秋
CBV特点
 能够直接根据请求方式的不同直接匹配到对应的方法执行
 
 内部到底是怎么实现的?
  CBV内部源码(******)
"""
原文地址:https://www.cnblogs.com/mayrain/p/13057573.html