1.views.py文件中的代码
class DemoView(View):
def get(self, request):
user = User.object.all()
list1 = []
for i in user:
data = {
'username': i.username,
'age': i.age,
'home': i.home
}
list1.append(data)
print(list1)
return JsonResponse({'data': list1})