I'm trying to build a query form in which user can encoded keywords. The result must show the offer that match the keyword following an "exclusive and". Therefore I use the Q module.
The keywords are split into a list and a loop is performed so I can build the query to be executed. But I somehow misunderstood something as it doesn't work at all.
Here is the code:
sentence = "Offer.objects.filter("
kw_list = keywords.split()
#kw_count = len(kw_list) could be useful if I perform a while loop
for kw in kw_list:
sentence += "Q(content__contains="+ kw +") & "
results = sentence + ")"