django __search - trying to do x+y__search

Posted by ckohrman on Stack Overflow See other posts from Stack Overflow or by ckohrman
Published on 2011-01-05T01:48:33Z Indexed on 2011/01/05 1:53 UTC
Read the original article Hit count: 605

Filed under:
|

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...

© Stack Overflow or respective owner

Related posts about django

Related posts about django-views