django 返回json数据
1 from django.core import serializers 2 3 @login_required 4 def ajax_get_data(request): 5 json_data = serializers.serialize("json", MyModel.objects.all()) 6 return HttpResponse(json_data,content_type="application/json")
1 from django.core import serializers 2 3 @login_required 4 def ajax_get_data(request): 5 json_data = serializers.serialize("json", MyModel.objects.all()) 6 return HttpResponse(json_data,content_type="application/json")