M
M
Michael2017-05-10 13:54:17
Django
Michael, 2017-05-10 13:54:17

How to implement logical OR in django?

How to correctly implement the request? The bottom line is, there is a search and it should look for matches in any of the three fields.

client = Client.objects.filter(Q(name = search) | Q(email = search) | Q(adres = search))

Gives an error ("The value of '[email protected]' must be True or False."])
And the option to search in any of the 2 fields works
client = Client.objects.filter(Q(name = search) | Q(email = search))

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Tallmange, 2017-05-10
@p00h

Maybe it will go like this?

client = Client.objects.filter(Q(name__exact=search) | Q(email__exact=search) | Q(adres__exact=search))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question