Views文件
#1.导入如下
from django.views.generic import View
#2.简写class类视图
class index1(View):
def get(self,request):
return JsonResponse({"menu":'get'})
def post(self,request):
return JsonResponse({"menu":'post'})
urls文件
re_path(r'^index1$',index1.as_view())