[Answered ]-How to filter with manytomany field?

3👍

If i understand your question right you have a specific site and your trying to filter by that site. Then you should filter like this:

site = Site.objects.get(pk=1)

mymodel_for_site = MyModel.objects.filter(field1=thing, sites=site)

This should get all the MyModel instances for a particular site

👤Pannu

-1👍

Try to make it via MyModel object, i.e.:

object = MyModel.objects.get(field1=thing)
qs = object.sites.all()

Check django docs

👤szaman

Leave a comment