Commit 4a9b9898 authored by Deokhyun Lee's avatar Deokhyun Lee

all the pages are correctly implemented.

parent 3b29bdda
{% extends 'base.html'%}
{% block title %}
{% if author %}
{{author.first_name}}{{author.last_name}}
{% else %}
<p>No Available Author.</p>
{% endif %}
{% endblock %}
{% block content %}
{% if author %}
<h1>{{author.first_name}} {{author.last_name}}</h1>
<ul>
{{author.age}}<br>
{{author.nationality}}<br>
{{author.bio}}<br>
</ul>
<h3>Books by {{author.first_name}} {{author.last_name}} I love: </h3>
{% if books %}
<ul>
{% for book in books %}
<a href="/books/{{book.id}}/details">{{ book.title }}</a><br>
{% endfor %}
</ul>
{% else %}
<p>No Available Books.</p>
{% endif %}
{% else %}
<p>No Available Author.</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
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
{% if authors %} {% if authors %}
<ul> <ul>
{% for author in authors %} {% for author in authors %}
<a href={{author.id}}/details>{{ author.first_name }}{{ author.last_name}}</a><br> <a href={{author.id}}/details>{{ author.first_name }} {{ author.last_name}}</a><br>
{% endfor %} {% endfor %}
</ul> </ul>
{% else %} {% else %}
......
...@@ -12,7 +12,8 @@ ...@@ -12,7 +12,8 @@
{% if book %} {% if book %}
<h1>{{book.title}}</h1> <h1>{{book.title}}</h1>
<ul> <ul>
{{book.author}}<br> <a href="/authors/{{book.author.id}}/details">{{book.author}}</a>
<br>
{{book.publisher}}<br> {{book.publisher}}<br>
{{book.year_published}}<br> {{book.year_published}}<br>
{{book.ISBN}}<br> {{book.ISBN}}<br>
......
...@@ -13,10 +13,19 @@ def home(request): ...@@ -13,10 +13,19 @@ def home(request):
# for Authors page # for Authors page
def authors(request): def authors(request):
context = {} authors = Author.objects.order_by('first_name')
context = {'authors': authors}
template = loader.get_template('authors/index.html') template = loader.get_template('authors/index.html')
return HttpResponse(template.render(context, request)) return HttpResponse(template.render(context, request))
def authors_detail(request, pk):
author = Author.objects.get(pk=pk)
# get books related to the author's id.
books = Books.objects.filter(author__pk = pk)
context = {'author': author, 'books': books}
template = loader.get_template('authors/author.html')
return HttpResponse(template.render(context, request))
# for Books page # for Books page
def books(request): def books(request):
......
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