Django 返回json代码
from assets.models import Resources
from django.core import serializers
from django.http import HttpResponse
def data_list(request):
res_list = Resources.objects.all()
res_list = serializers.serialize("json", res_list)
return HttpResponse(res_list)
curll 解析命令
curl -X post http://192.168.5.21:8000/client/data_list > mainpage.html
原因在于没有在后边追加一个 “/”,将上述的命令修改为:
curl -X post http://192.168.5.21:8000/client/data_list/ > mainpage.html