我正在使用 Django 的 ORM 从数据库中获取新添加的条目并将它们传递给消息队列。我在无限循环中执行此操作,每次循环迭代中的问题即使在此脚本运行时添加/删除/编辑条目,我也会得到相同的查询集,
代码如下:
while True :
sleep(10 seconds)
# Below is the problem line, I get the same query-set every time in new_objects
# even when I have added/deleted/edited entries while this daemon is running.
new_objects = Model.objects.filter(some condition)
# Process new_objects and send them to MQ
.
. and so on
我应该怎么做才能反映每次迭代中的最新数据?