[Django]-Filtering Many-to-Many relationship by Relationship field in Django

50👍

You can query across relationships with the django ORM (or in this case the reverse relationship):

person = Person.objects.filter(
    membership__group=example_group,
    membership__date_joined__gte=example_date
)

0👍

You can also do this:

person = example_group.members.filter(
    membership__date_joined__gte=example_date
)
👤flix

Leave a comment