1👍
✅
Give this a try:
from django.db.models import Q
qs = Order.objects.filter(status='New').filter(
Q(operator=self.request.user) | Q(operator=None),
Q(referral_user__in=self.request.user.operators.all()) | Q(referral_user__orders_for_all_operators=True)
)
Source:stackexchange.com