首页 > 解决方案 > 在 Django 返回对象中获取最新 ID 是不可迭代的

问题描述

我试图在 Django 中获取最新的 id,但得到了错误。

def getlatestid(request):
    cot_info = COT.objects.latest('id')
    return JsonResponse({"data": list(cot_info)})

TypeError: 'COT' object is not iterable

标签: django

解决方案


推荐阅读