Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
Deokhyun_Lee_reading
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Deokhyun Lee
Deokhyun_Lee_reading
Commits
4a9b9898
Commit
4a9b9898
authored
Mar 27, 2023
by
Deokhyun Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
all the pages are correctly implemented.
parent
3b29bdda
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
47 additions
and
3 deletions
+47
-3
urls.cpython-39.pyc
bookshelf/__pycache__/urls.cpython-39.pyc
+0
-0
views.cpython-39.pyc
bookshelf/__pycache__/views.cpython-39.pyc
+0
-0
author.html
bookshelf/templates/authors/author.html
+34
-0
index.html
bookshelf/templates/authors/index.html
+1
-1
book.html
bookshelf/templates/books/book.html
+2
-1
views.py
bookshelf/views.py
+10
-1
No files found.
bookshelf/__pycache__/urls.cpython-39.pyc
View file @
4a9b9898
No preview for this file type
bookshelf/__pycache__/views.cpython-39.pyc
View file @
4a9b9898
No preview for this file type
bookshelf/templates/authors/author.html
0 → 100644
View file @
4a9b9898
{% 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
bookshelf/templates/authors/index.html
View file @
4a9b9898
...
...
@@ -9,7 +9,7 @@
{% if authors %}
<ul>
{% 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 %}
</ul>
{% else %}
...
...
bookshelf/templates/books/book.html
View file @
4a9b9898
...
...
@@ -12,7 +12,8 @@
{% if book %}
<h1>
{{book.title}}
</h1>
<ul>
{{book.author}}
<br>
<a
href=
"/authors/{{book.author.id}}/details"
>
{{book.author}}
</a>
<br>
{{book.publisher}}
<br>
{{book.year_published}}
<br>
{{book.ISBN}}
<br>
...
...
bookshelf/views.py
View file @
4a9b9898
...
...
@@ -13,9 +13,18 @@ def home(request):
# for Authors page
def
authors
(
request
):
context
=
{}
authors
=
Author
.
objects
.
order_by
(
'first_name'
)
context
=
{
'authors'
:
authors
}
template
=
loader
.
get_template
(
'authors/index.html'
)
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment