[英]How I can get all rows with booleanField equal to false?
I am trying to return all the rows with BooleanField equal true
or false
. 我试图返回BooleanField等于
true
或false
所有行。 I am using python django, the field name and field value store in dict: 我正在使用python django,字段名称和字段值存储在dict中:
books = Book.objects.filter(**book_dict).prefetch_related(prefetch).select_related(
'book_pdf',
'book__pdf_file').distinct('id')
The dict contains: {'fieldName__in': 'False'}
and the actual query it always 'select ... where fieldName in (True)' I tryed to change the dict to: {'fieldName__in': 'false'}
and got the same result, and also change to: {'fieldName__in': False}
and got error: "bool is not iterable" 该字典包含:
{'fieldName__in': 'False'}
和实际查询始终为'select ... where fieldName in(True)'我试图将字典更改为: {'fieldName__in': 'false'}
并得到结果相同,并且也更改为: {'fieldName__in': False}
并得到错误:“布尔不可迭代”
I don't understand why you're using __in
, or why you're using a string for the value. 我不明白为什么要使用
__in
,或者为什么要使用字符串作为值。 It should just be: {'fieldname': False}
with no quotes. 它应该只是:
{'fieldname': False}
,不带引号。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.