客户端从两个表中获取数据。这是文件中的代码views.py
:
...
dbdataA = TableA.objects.filter(user=user)
dbdataB = TableB.objects.filter(user=user).order_by("field1")
result_list = list(chain(orders, alldata))
msg = serializers.serialize("json", result_list, fields=("field1","field2","field3","field4"), use_natural_keys=True)
return HttpResponse(msg)
我需要添加一个具有当前响应时间的变量。这个怎么做?
UPD: 传递给链(订单,所有数据,...)的任何数据都会在字符串“msg =serializers.serialize...”中给出错误“'str' object has no attribute '_meta'”。可能是因为chain()除了iterable之外不能取任何数据,但是(time.asctime(time.localtime())是不可迭代的?