django - 在 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
解决方案
推荐阅读
- c - 编写从标准输入读取并打印到标准输出的 ac 程序,没有内置的行长限制
- javascript - 如何检查承诺是否已解决并有条件地渲染 Javascript?
- scala - 如何验证 Scala 二进制文件?
- java - Kafka 向 Spark Streaming 发送消息时出错
- database-design - 可以从过去的数据库状态中选择的版本化数据库引擎?
- javascript - 编辑时输入 http://localhost:8000/controller/1 500(内部服务器错误)
- angular - Ionic v4 - 检查模态是否打开
- fetchmail - 需要立即从邮件服务器获取邮件
- javascript - 映射对象数组并根据名字过滤
- tensorflow - GAN 没有多 GPU 加速