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

后端 未结 1 977
无人及你
无人及你 2020-12-28 14:48

I\'m trying to filter many-to-many relationship by some through Class field.

Quoting the Django documentation, i will explain my goal



        
相关标签:
1条回答
  • 2020-12-28 15:29

    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 讨论(0)
提交回复
热议问题