python - How to check if a string contains any one of the value of a list in a query in Django ORM -


i need create query in want check if field "answer_string" contains 1 of value list.

i did in way:

q=queryset.filter(reduce(operator.and_, (q(answer_string__contains = item) item in answerlist))) 

there no. of checkboxes user can select multiple answers , have created list.any value in answer_string field can contain multiple answers in string. want check if string contains 1 of value list should take yes.

this query wrote returns me 0 results. please?

if want check if field contains "any" value of list use operator.or_

operator.and_ concatenates smaller q objects and. current query searching field value contains list values.


Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -