4👍
Use select_related()
YourModel.objects.select_related().filter(foreign_record__foreign_attribute__gt=foo)
The select_related gets translated to INNER JOIN query and loads all the data immediately.
Source:stackexchange.com
4👍
Use select_related()
YourModel.objects.select_related().filter(foreign_record__foreign_attribute__gt=foo)
The select_related gets translated to INNER JOIN query and loads all the data immediately.