django filter on related field

  1. To filter on a related field in Django, start by using the double underscore notation to access the related field in your filter query.
  2. For example, if you have a model called Author with a related field called book_set, you can filter for authors who have written books with a specific title using the following query: Author.objects.filter(book_set__title='YourTitle').
  3. In this example, book_set is the related field, and title is the field on the related model that you want to filter by.