📜  将 queryset 转换为 json django - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:32.536000             🧑  作者: Mango

代码示例2
from django.http import JsonResponse

def some_view(request):
    data = list(SomeModel.objects.values())  # wrap in list(), because QuerySet is not JSON serializable
    return JsonResponse(data, safe=False)  # or JsonResponse({'data': data})