django ajax返回500

页面respnse输出Object of type 'QuerySet' is not JSON serializable错误
解决:(views.py)

from django.http import JsonResponse
from django.core import serializers
def xx(request,num):
    data = serializers.serialize("json",XXXX.objects.all().filter(xxxx=num))
    return JsonResponse(data,safe=False)

1,serializers.serialize("json",
2, safe=False)

你可能感兴趣的:(django ajax返回500)