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")
时间: 2024-11-09 00:30:19
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")