django __search - trying to do x+y__search
- by ckohrman
I'm trying to do something like this with django:
Q(x+y__search = z)
I'm using __search to boolean search for a list of words within two
separate lists (requiredTags, preferredTags). Line 10 is the one I
have questions about. I want to see if the list of words (requTags)
is found among requiredTags or preferredTags.
requTags=""
prefeTags=""
for i in reqTags:
if(i!=""):
requTags+="+"+i+" "
for i in prefTags:
if(i!=""):
prefeTags+=i+" "
if(requTags!=""):
query=query &( Q(requiredTags__search + preferredTags__search = requTags))
if(prefeTags!=""):
query=query &( Q(requiredTags__search = prefeTags) | Q(preferredTags__search = prefeTags))
For instance:
requTags might be: +beans +rice +cheese.
requiredTags might be: beans,rice,tortilla
preferredTags might be: cheese
I didn't see any way to combine requiredTags and preferredTags in the
documentation. Any help would be appreciated as I'm a beginner...