0

I have Django list view but I want to put search based on two columns. how to implement this. User would be able to search records based on two columns in same view.

1 Answer 1

1

I think you can do it by | and using Q like below:

from django.db.models import Q

YourModel.objects.filter(Q(column_1__icontains=searched_keyword) | Q(
                column_2__icontains=searched_keyword))

I think this can help.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.