1👍
✅
if it is a foreignkey you can do something like this
team_stats=NCAABTeamStats.objects.select_related('name').filter(name__name__in=teams_playing).order_by(sort)
you can learn more on select_related here
if it is a manytomany field you can do something like this
team_stats=NCAABTeamStats.objects.prefetch_related('name').filter(name__name__in=teams_playing).order_by(sort)
you can learn more on prefetch_related Here
Source:stackexchange.com