在Django模型查询集中,我看到比较值有__gt
和__lt
,但有__ne
或!=
(not equals)吗?我想用not equals过滤掉.例如
Model:
bool a;
int x;
我想做
results = Model.objects.exclude(a=True, x!=5)
!=
的语法不正确.我也试过__ne
.
我最终使用了:
results = Model.objects.exclude(a=True, x__lt=5).exclude(a=True, x__gt=5)