Python--day72--Django内置的serializers序列化介绍

序列化

Django内置的serializers

def books_json(request):
    book_list = models.Book.objects.all()[0:10]
    from django.core import serializers
    ret = serializers.serialize("json", book_list)
    return HttpResponse(ret)
posted @ 2019-04-12 17:15  莱茵河的雨季  阅读(446)  评论(1编辑  收藏  举报