CBV和FBV
作者:互联网
FBV
FBV: function based view
就是平常在views.py中写的函数
from django.shortcuts import render, HttpResponse # Create your views here. from django.http import JsonResponse def test(request): user_dict = {'username': '阿飞', 'password': '123'} l = [111, 222, 333] return JsonResponse(l, safe=False)
CBV
CBV: class based view
写法:
class IndexView(View): def get(self, request): print('get') return HttpResponse('get') def post(self, request): print('post') return HttpResponse('POST')
源码解析
八大请求
标签:return,FBV,get,request,CBV,HttpResponse 来源: https://www.cnblogs.com/zhaoyuanshi/p/15956148.html