0

我有这个查询:

countries = Country.objects.filter(country_desc='')

怎么样country_desc != ''?下面的查询返回没有描述的国家,但对于其他有描述的国家,我尝试过这个查询:

countries = Country.objects.filter(~Q(country_desc=''))

但它不起作用。它返回给我一个错误:

关键字 arg 后的非关键字 arg

还有其他有效的方法吗?

4

1 回答 1

1

只需使用排除而不是过滤器:)

countries = Country.objects.exclude(country_desc='')
于 2013-06-27T13:31:53.160 回答