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内部源码(******)
"""

 

posted @ 2020-06-06 23:07  五月雨变奏  阅读(155)  评论(0编辑  收藏  举报