The documentation for Django QuerySet API explains how to filter results using field lookups. The problem I have is that this approach requires the left hand operand to be a field and I need it to be an expression, to achieve the equivalent of (' ' || tagnames || ' ') LIKE '% xyz %'.
What’s the best way to do this? To clarify what I mean by “best”: I’m hoping for something that will be independent of the actual database used.
One way you can accomplish this is the following (not sure if it’s necessarily the best way):
Also, you can always just use the actual SQL you’re wanting to use with the
rawmethod.