Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
janang_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
Jan Ericsson Ong Ang
janang_reading
Commits
8493324d
Commit
8493324d
authored
Mar 30, 2023
by
Jan Ericsson Ong Ang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed views.py and urls.py to show books & author
parent
1b9b05cd
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
16 additions
and
15 deletions
+16
-15
urls.cpython-310.pyc
janang_reading/bookshelf/__pycache__/urls.cpython-310.pyc
+0
-0
views.cpython-310.pyc
janang_reading/bookshelf/__pycache__/views.cpython-310.pyc
+0
-0
author_details.html
...reading/bookshelf/templates/bookshelf/author_details.html
+1
-1
authors.html
janang_reading/bookshelf/templates/bookshelf/authors.html
+1
-1
book_details.html
...g_reading/bookshelf/templates/bookshelf/book_details.html
+2
-2
books.html
janang_reading/bookshelf/templates/bookshelf/books.html
+1
-1
home.html
janang_reading/bookshelf/templates/bookshelf/home.html
+1
-1
urls.py
janang_reading/bookshelf/urls.py
+4
-3
views.py
janang_reading/bookshelf/views.py
+6
-6
No files found.
janang_reading/bookshelf/__pycache__/urls.cpython-310.pyc
View file @
8493324d
No preview for this file type
janang_reading/bookshelf/__pycache__/views.cpython-310.pyc
View file @
8493324d
No preview for this file type
janang_reading/bookshelf/templates/bookshelf/author_details.html
View file @
8493324d
...
...
@@ -14,6 +14,6 @@
<a
href=
"/bookshelf/"
>
Home
</a>
<a
href=
"/bookshelf/books/"
>
Books
</a>
<a
href=
"/bookshelf/author/"
>
Authors
</a>
<a
href=
"/bookshelf/author
s
/"
>
Authors
</a>
{% endblock %}
\ No newline at end of file
janang_reading/bookshelf/templates/bookshelf/authors.html
View file @
8493324d
...
...
@@ -7,7 +7,7 @@
{% block header %}
<h1>
{{ nickname }}'s Favorite Authors:
</h1>
{% endblock %}
<br>
{% for author in authors %}
<a
href=
"/bookshelf/author/{{ author.pk }}/details/"
>
{{ author.first_name }} {{ author.last_name }}
</a>
<a
href=
"/bookshelf/author
s
/{{ author.pk }}/details/"
>
{{ author.first_name }} {{ author.last_name }}
</a>
{% endfor %}
<br>
...
...
janang_reading/bookshelf/templates/bookshelf/book_details.html
View file @
8493324d
...
...
@@ -5,7 +5,7 @@
{% block content %}
{% block header %}
<h1>
{{ books.title }}
</h1>
{% endblock %}
<a
href=
"/bookshelf/author/{{ books.author.pk }}/details/"
>
{{ books.author.pk }}
</a><br>
<a
href=
"/bookshelf/author
s
/{{ books.author.pk }}/details/"
>
{{ books.author.pk }}
</a><br>
<p>
{{ books.publisher }}
</p>
<p>
{{ books.year_published }}
</p>
<p>
{{ books.year_ISBN }}
</p>
...
...
@@ -13,6 +13,6 @@
<a
href=
"/bookshelf/"
>
Home
</a>
<a
href=
"/bookshelf/books/"
>
Books
</a>
<a
href=
"/bookshelf/author/"
>
Authors
</a>
<a
href=
"/bookshelf/author
s
/"
>
Authors
</a>
{% endblock %}
\ No newline at end of file
janang_reading/bookshelf/templates/bookshelf/books.html
View file @
8493324d
...
...
@@ -12,6 +12,6 @@
<br>
<a
href=
"/bookshelf/"
>
Home
</a>
<a
href=
"/bookshelf/author/"
>
Authors
</a>
<a
href=
"/bookshelf/author
s
/"
>
Authors
</a>
{% endblock %}
\ No newline at end of file
janang_reading/bookshelf/templates/bookshelf/home.html
View file @
8493324d
...
...
@@ -10,6 +10,6 @@
</p>
<a
href=
"/bookshelf/books/"
>
Books
</a>
<a
href=
"/bookshelf/author/"
>
Authors
</a>
<a
href=
"/bookshelf/author
s
/"
>
Authors
</a>
{% endblock %}
\ No newline at end of file
janang_reading/bookshelf/urls.py
View file @
8493324d
from
django.urls
import
path
from
.
import
views
from
.views
import
HomeView
,
AuthorView
,
AuthorDetailView
,
BooksView
,
BookDetailView
# url for bookshelf
urlpatterns
=
[
path
(
''
,
HomeView
.
as_view
()
,
name
=
'home'
),
path
(
'author
/'
,
AuthorView
.
as_view
(),
name
=
'author
'
),
path
(
'author/<int:pk>/details/'
,
AuthorDetailView
.
as_view
(),
name
=
'author-detail'
),
path
(
''
,
views
.
HomeView
,
name
=
'home'
),
path
(
'author
s/'
,
AuthorView
.
as_view
(),
name
=
'authors
'
),
path
(
'author
s
/<int:pk>/details/'
,
AuthorDetailView
.
as_view
(),
name
=
'author-detail'
),
path
(
'books/'
,
BooksView
.
as_view
(),
name
=
'books'
),
path
(
'books/<int:pk>/details/'
,
BookDetailView
.
as_view
(),
name
=
'books-detail'
),
]
...
...
janang_reading/bookshelf/views.py
View file @
8493324d
...
...
@@ -6,24 +6,24 @@ from .models import Author, Books
# Create your views here.
class
HomeView
(
View
):
def
get
(
self
,
request
):
def
HomeView
(
request
):
return
render
(
request
,
'bookshelf/home.html'
,
{
'nickname'
:
'Jan'
})
class
AuthorView
(
ListView
):
model
=
Author
def
get
(
self
,
request
):
return
render
(
request
,
'bookshelf/author.html'
,
{
'nickname'
:
'Jan'
})
model
=
Author
return
render
(
request
,
'bookshelf/authors.html'
,
{
'nickname'
:
'Jan'
})
class
AuthorDetailView
(
DetailView
):
model
=
Author
template_name
=
'bookshelf/author_details.html'
class
BooksView
(
ListView
):
model
=
Books
def
get
(
self
,
request
):
model
=
Books
return
render
(
request
,
'bookshelf/books.html'
,
{
'nickname'
:
'Jan'
})
class
BookDetailView
(
DetailView
):
model
=
Books
template_name
=
'bookshelf/books_details.html'
\ No newline at end of file
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