'Reverse query via foreign key and many to many field in Django

What query can I use to return all the Organisation objects that are members of a certain membership_id value?

e.g. return all Organisation objects that have a membership_id = 101

class Organisations(model)
    id = models.CharField()
    memberships = models.ManyToManyField("self", through="Memberships")

class Memberships(model)
    membership_id = models.IntegerField()
    organisation_id = models.ForeignKey(Organisations, related_name="orgs",)


Solution 1:[1]

Try this:

Organisations.objects.filter(orgs__membership_id=101)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Toms Code