[Answered ]-Django conditional many-to-many relation exists check

1👍

You can .filter(…) [Django-doc] with:

from django.db.models import Q

Feed.objects.filter(Q(visibility_setting=0) | Q(visible_to=my_user)).distinct()

the .distinct() call [Django-doc]
prevents returning the same Feed multiple times.

Leave a comment