我试图在Django中获得最新的id,但得到了错误。
def getlatestid(request):
    cot_info = COT.objects.latest('id')
    return JsonResponse({"data": list(cot_info)})
TypeError: 'COT' object is not iterable发布于 2020-06-02 05:47:45
返回一个对象,而不是一个列表。因此,您可以尝试这样来修复错误:
def getlatestid(request):
    cot_info = COT.objects.values().latest('id')
    return JsonResponse({"data": cot_info})https://stackoverflow.com/questions/62145525
复制相似问题