from django.core import serializers @login_required def ajax_get_data(request): json_data = serializers.serialize("json", MyModel.objects.all()) return HttpResponse(json_data,content_type="application/json")
objectQuerySet = ConventionCard.objects.filter(ownerUser = user) data = serializers.serialize(‘json‘, list(objectQuerySet), fields=(‘fileName‘,‘id‘))
原文:http://www.cnblogs.com/zhaojia-dream/p/4335307.html