Commit 3b29bdda authored by Deokhyun Lee's avatar Deokhyun Lee

now pages for books and books

parent 0ca477be
{% extends 'base.html'%} {% extends 'base.html'%}
{% block title %} {% block title %}
My Favorite Books & Authors My Favorite Authors
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<h1>Welcome to Deokhyun's Database of Favorite Books and Authors!</h1> <h1>Deokhyun's Favorite Authors:</h1>
<p>My personal preference: {% if authors %}
<p>I love reading fantasy or Science Fiction! <ul>
Therefore, Frank Herbert's {% for author in authors %}
Dune is one of the best <a href={{author.id}}/details>{{ author.first_name }}{{ author.last_name}}</a><br>
American authors for me!</p></p> {% endfor %}
<a href="/books">Books</a>&nbsp&nbsp&nbsp&nbsp&nbsp<a href="/authors">Authors</a> </ul>
{% else %}
<p>No Available Authors.</p>
{% endif %}
<a href="/home">Home</a>&nbsp&nbsp&nbsp&nbsp&nbsp <a href="/books">Books</a>
{% endblock %} {% endblock %}
\ No newline at end of file
{% extends 'base.html'%}
{% block title %}
{% if book %}
{{book.title}}
{% else %}
<p>No Available Books.</p>
{% endif %}
{% endblock %}
{% block content %}
{% if book %}
<h1>{{book.title}}</h1>
<ul>
{{book.author}}<br>
{{book.publisher}}<br>
{{book.year_published}}<br>
{{book.ISBN}}<br>
{{book.blurb}}<br>
</ul>
{% else %}
<p>No Available Books.</p>
{% endif %}
<a href="/home">Home</a>&nbsp&nbsp&nbsp&nbsp&nbsp<a href="/books">Books</a>&nbsp&nbsp&nbsp&nbsp&nbsp<a href="/authors">Authors</a>
{% endblock %}
\ No newline at end of file
...@@ -6,5 +6,14 @@ ...@@ -6,5 +6,14 @@
{% block content %} {% block content %}
<h1>Deokhyun's Favorite Books:</h1> <h1>Deokhyun's Favorite Books:</h1>
{% if books %}
<ul>
{% for book in books %}
<a href={{book.id}}/details>{{ book.title }}</a><br>
{% endfor %}
</ul>
{% else %}
<p>No Available Books.</p>
{% endif %}
<a href="/home">Home</a>&nbsp&nbsp&nbsp&nbsp&nbsp<a href="/authors">Authors</a>
{% endblock %} {% endblock %}
\ No newline at end of file
...@@ -11,4 +11,5 @@ ...@@ -11,4 +11,5 @@
Therefore, Frank Herbert's Therefore, Frank Herbert's
Dune is one of the best Dune is one of the best
American authors for me!</p></p> American authors for me!</p></p>
<a href="/books">Books</a>&nbsp&nbsp&nbsp&nbsp&nbsp<a href="/authors">Authors</a>
{% endblock %} {% endblock %}
\ No newline at end of file
...@@ -4,5 +4,7 @@ from . import views ...@@ -4,5 +4,7 @@ from . import views
urlpatterns = [ urlpatterns = [
path('home/', views.home, name = "home"), path('home/', views.home, name = "home"),
path('books/', views.books, name = "books"), path('books/', views.books, name = "books"),
path('authors/', views.authors, name = "authors") path('books/<int:pk>/details', views.books_detail, name = "books_detail"),
path('authors/', views.authors, name = "authors"),
path('authors/<int:pk>/details', views.authors_detail, name = "authors_detail"),
] ]
\ No newline at end of file
...@@ -20,7 +20,13 @@ def authors(request): ...@@ -20,7 +20,13 @@ def authors(request):
# for Books page # for Books page
def books(request): def books(request):
context = {} books = Books.objects.order_by('year_published')
context = {'books': books}
template = loader.get_template('books/index.html') template = loader.get_template('books/index.html')
return HttpResponse(template.render(context, request)) return HttpResponse(template.render(context, request))
def books_detail(request, pk):
book = Books.objects.get(pk=pk)
context = {'book': book}
template = loader.get_template('books/book.html')
return HttpResponse(template.render(context, request))
\ No newline at end of file
...@@ -8,6 +8,5 @@ ...@@ -8,6 +8,5 @@
<div class="container"> <div class="container">
{% block content %}{% endblock %} {% block content %}{% endblock %}
</div> </div>
<a href="/books">Books</a>&nbsp&nbsp&nbsp&nbsp&nbsp<a href="/authors">Authors</a>
</body> </body>
</html> </html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment