zoukankan      html  css  js  c++  java
  • 使用serialize时多数据传递

    class CartList(APIView):
    #定义编辑方法
    def post(self,request):
    username = request.POST.get('username')
    # print(username)
    idlist = cache.get(username)
    sum = len(idlist)
    test_dict = {}
    #遍历数组
    for key in idlist:
    #通过key来计算元素个数
    test_dict[key] = test_dict.get(key,0) + 1
    print(test_dict)
    # print(idlist)
    for i in idlist:
    res = CommoDity.objects.filter(id__in=idlist)
    print(type(test_dict))
    data = serialize('json',res,ensure_ascii=False)
    return Response([test_dict,data,sum])
     
     
    注:Response内用列表形式进行多数据传递  忘谨记
  • 相关阅读:
    mkdir,rmdir
    linux目录结构
    echo
    date
    man
    cd
    ls
    线程、进程
    php类型的自动转换
    电商
  • 原文地址:https://www.cnblogs.com/wjohh/p/10674422.html
Copyright © 2011-2022 走看看