class Human(models.Model):
salary = models.IntegerField()
payments = models.IntegerField()
objects = HumansManager()
}}}
`is_in_trouble` works for
* `Human.objects.first().is_in_trouble`
* `Human.objects.values('is_in_trouble')`
But
`Human.objects.filter(is_in_trouble=True)` leads to
{{{
File "C:\spam\Python36-32\lib\site-packages\django\db\models\query.py",
line 246, in __repr__
data = list(self[:REPR_OUTPUT_SIZE + 1])
File "C:\spam\Python36-32\lib\site-packages\django\db\models\query.py",
line 270, in __iter__
self._fetch_all()
File "C:\spam\Python36-32\lib\site-packages\django\db\models\query.py",
line 1178, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "C:\spam\Python36-32\lib\site-packages\django\db\models\query.py",
line 55, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch,
chunk_size=self.chunk_size)
File "C:\spam\Python36-32\lib\site-
packages\django\db\models\sql\compiler.py", line 1049, in execute_sql
sql, params = self.as_sql()
File "C:\spam\Python36-32\lib\site-
packages\django\db\models\sql\compiler.py", line 458, in as_sql
where, w_params = self.compile(self.where) if self.where is not None
else ("", [])
File "C:\spam\Python36-32\lib\site-
packages\django\db\models\sql\compiler.py", line 390, in compile
sql, params = node.as_sql(self, self.connection)
File "C:\spam\Python36-32\lib\site-
packages\django\db\models\sql\where.py", line 79, in as_sql
sql, params = compiler.compile(child)
File "C:\spam\Python36-32\lib\site-
packages\django\db\models\sql\compiler.py", line 390, in compile
sql, params = node.as_sql(self, self.connection)
File "C:\spam\Python36-32\lib\site-
packages\django\db\models\lookups.py", line 160, in as_sql
lhs_sql, params = self.process_lhs(compiler, connection)
File "C:\spam\Python36-32\lib\site-
packages\django\db\models\lookups.py", line 151, in process_lhs
lhs_sql, params = super().process_lhs(compiler, connection, lhs)
File "C:\spam\Python36-32\lib\site-
packages\django\db\models\lookups.py", line 77, in process_lhs
lhs = lhs.resolve_expression(compiler.query)
File "C:\spam\Python36-32\lib\site-
packages\django\db\models\expressions.py", line 248, in resolve_expression
for expr in c.get_source_expressions()
File "C:\spam\Python36-32\lib\site-
packages\django\db\models\expressions.py", line 248, in <listcomp>
for expr in c.get_source_expressions()
AttributeError: 'WhereNode' object has no attribute 'resolve_expression'
}}}
It really confusing.
--
Ticket URL: <https://code.djangoproject.com/ticket/28826>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => duplicate
Comment:
Duplicate of #28863 which points out that this is a regression in Django
2.0.
--
Ticket URL: <https://code.djangoproject.com/ticket/28826#comment:1>