-1

我有疑问:

users_to_exclude = MyModel.objects.filter(status=1)

现在:

result = MyAnotherModel.objects.filter(image=my_image).count()

和:

result = MyAnotherModel.objects.filter(image=my_image).exclude(user__in=users_to_exclude).count()

向我显示相同的数字(users_to_exclude有正确的数据)。如何做好?

4

1 回答 1

1

阅读该主题:

https://docs.djangoproject.com/en/dev/ref/models/querysets/#in

还有:

You can also use a queryset to dynamically evaluate the list of values instead of providing a list of literal values:
于 2013-06-27T11:53:48.847 回答