[Django]-Django filter from two fields with single input

7👍

Your code searches for jobs where BOTH title AND skills contain request.GET['skills']. To search for jobs where title OR skills (or both) contain request.GET['skills'], you have to use Q objects:

from django.db.models import Q
...
search = request.GET['skills']
        #     skills contain search  OR  title contains search
query = Q(skills__icontains=search ) | Q(title__icontains=search )
job.objects.filter(query)

Leave a comment