我有一个 list
customers=Customers.objects.filter(limit=1)
level1=customers.filter(status=1)
level2=customers.filter(status=2)
我想填充第三个列表,该列表必须包含 customers
但不在 level1
和 level2
中的所有客户的名称/p>
我试过这么多
returned=customers.filter(~level1)
最佳答案
您可以使用 exclude() :
Customers.objects.exclude(status__in=[1,2])
或
Customers.objects.filter(whatever=whatever).exclude(status__in=[1,2])
关于python - 不在 Python 中过滤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17291768/