Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Last active August 25, 2020 06:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save velotiotech/2b2ab3bc53243fffc7b1df021158aff9 to your computer and use it in GitHub Desktop.
Save velotiotech/2b2ab3bc53243fffc7b1df021158aff9 to your computer and use it in GitHub Desktop.
>> queryset = Book.objects.select_related("author").all()
>> print(queryset.query)
SELECT "core_book"."id",
"core_book"."name",
"core_book"."author_id",
"core_book"."created_at",
"core_author"."id",
"core_author"."name"
FROM "core_book"
INNER JOIN "core_author" ON ("core_book"."author_id" = "core_author"."id")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment