Opened 8 hours ago
#35972 new Bug
Custom lookup example raises TypeError
Reported by: | Jacob Walls | Owned by: | |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
On the forum I shared the TypeError I was getting when registering a custom lookup for a JSONField
:
File models/lookups.py:13, in NotEqual.as_sql(self, compiler, connection) 11 lhs, lhs_params = self.process_lhs(compiler, connection) 12 rhs, rhs_params = self.process_rhs(compiler, connection) ---> 13 params = lhs_params + rhs_params 14 return "%s <> %s" % (lhs, rhs), params TypeError: can only concatenate list (not "tuple") to list
Since this problematic pattern is documented, we should either fix the documentation or fix the underlying reason it doesn't work. I haven't looked into whether there are backwards-compatible ways to do the latter.
Reproduction is just to follow the documented pattern and register it with a JSONField e.g. @JSONField.register_lookup
, and then try to use it in an ORM query.
Note:
See TracTickets
for help on using tickets.