How to combine multiple querysets and remove duplicates? How to combine multiple querysets and remove duplicates? django django

How to combine multiple querysets and remove duplicates?


I think that you want something like this:

from django.db.models import QResource.objects.filter(Q(name__icontains=tag) | Q(tags__name__in=tags)).filter(isActive=True).order_by('-score').distinct()

Q objects documentation