[Answer]-Fetching data from Django models related via foreign key

1👍

This is the easy and efficient way:

users = ( User
          .objects
          .filter( email__attachment__name = 'Picture1.jpg' )
          .distinct()
        )

Remember to create needed indexes to your database tables.

Leave a comment