首页 > 其他 > 详细

django 自带序列化组件效果

时间:2019-11-25 23:56:29      阅读:171      评论:0      收藏:0      [点我收藏+]

 

from django.core import serializers
def tt(request):
    data = request.GET
    data = dict(data)
    print(data)
    real_dict = {}
    for k, v in data.items():
        real_dict[k] = v[0]
    name = data["name"][0]
    id = data["id"][0]
    obj = FF(id=id,name=name)
    obj.save()

    obj = FF.objects.all()
    ret = serializers.serialize("json", obj)
    return HttpResponse(ret)

  返回值

[
    {
        "model": "app01.ff",
        "pk": 1,
        "fields": {
            "pdf": "",
            "name": "李四"
        }
    },
    {
        "model": "app01.ff",
        "pk": 2,
        "fields": {
            "pdf": "/Users/。。。/static/张三/sql查询语句_mbpEz2K.pdf",
            "name": "张三"
        }
    },
    {
        "model": "app01.ff",
        "pk": 3,
        "fields": {
            "pdf": "/Users/。。。/static/张三/sql查询语句_VPbGcYQ.pdf",
            "name": "张三"
        }
    }
]

  

 

django 自带序列化组件效果

原文:https://www.cnblogs.com/realadmin/p/11932184.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!