Skip to content

Instantly share code, notes, and snippets.

@PaulSebalu
Last active March 18, 2022 15:54
Show Gist options
  • Save PaulSebalu/847a0b8f9439ce37cafe685f3ba788aa to your computer and use it in GitHub Desktop.
Save PaulSebalu/847a0b8f9439ce37cafe685f3ba788aa to your computer and use it in GitHub Desktop.
# Link to repo: https://github.com/PaulSebalu/bookstore
# using the interactive shell: "python manage.py shell"
from store.models import Book
books = Book.objects.select_related('author').all()
for book in books:
f"\"{book.title}\". {book.author.name}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment