Skip to content

Instantly share code, notes, and snippets.

@valerybriz
Created May 2, 2019 21:57
Show Gist options
  • Save valerybriz/3bc7e2fa6a2007e8223665a33db1239c to your computer and use it in GitHub Desktop.
Save valerybriz/3bc7e2fa6a2007e8223665a33db1239c to your computer and use it in GitHub Desktop.
# Hits the database
team_queryset = Team.objects.select_related("user").get(name="tigers")
# The second line doesn't hit the database, because team_queryset.user has been previously prepopulated
user = team_queryset.user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment