CBV与FBV
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')
源码解析


八大请求


浙公网安备 33010602011771号