如何过滤查询,以便结果排除ID属于列表的任何对象实例?
可以说我有:
object_id_list = [1, 5, 345]
MyObject.objects.filter(Q(time__gte=datetime.now()) & Q( ... what to put here? ... ))
风格的东西 "SELECT * FROM ... WHERE id NOT IN (...)"
Answers:
MyObject.objects.filter(time__gte=datetime.now()).exclude(id__in=object_id_list)
.objects
。它是什么?
MyObject.objects
什么?我在哪里可以读到这堂课?