Skip to content

Commit

Permalink
shows models in html
Browse files Browse the repository at this point in the history
  • Loading branch information
heloisatambara committed May 17, 2023
1 parent 0795c87 commit 4ebe3df
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions books/templates/index.html
Expand Up @@ -8,5 +8,11 @@
</head>
<body>
Hello world

<ul>
{% for book in books %}
<li> {{ book.id }} - {{ book.title }} by {{ book.author }}</li>
{% endfor %}
</ul>
</body>
</html>
4 changes: 3 additions & 1 deletion books/views.py
@@ -1,5 +1,7 @@
from django.shortcuts import render
from .models import Book

# Create your views here.
def home(request):
return render(request, "index.html")
books = Book.objects.all()
return render(request, "index.html", {"books": books})

0 comments on commit 4ebe3df

Please sign in to comment.