def get(self, request, *args, **kwargs): tool = Tools() datalist = tool.class_list_data(1) data = { "num": self.count, "datalist": datalist, } return render(request, "classes.html", { "classesmsg": self.classesmsg, "pagename": self.pagename, "data": data })
def post(self, request, *args, **kwargs): tool = Tools() num = request.POST.get("num") datalist = list(tool.class_list_data(num)) print(datalist) # datalist = model_to_dict(data_list) # print(datalist) # datalist = serializers.serialize('json', datalist) data = { "classesmsg": self.classesmsg, "datalist": datalist, } data = json.dumps(data) print(data) return HttpResponse(data)