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
b9e8b471
Commit
b9e8b471
authored
Mar 30, 2023
by
Jan Ericsson Ong Ang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed author and book for loops
parent
407bc54d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
5 deletions
+13
-5
views.cpython-310.pyc
janang_reading/bookshelf/__pycache__/views.cpython-310.pyc
+0
-0
authors.html
janang_reading/bookshelf/templates/bookshelf/authors.html
+3
-1
books.html
janang_reading/bookshelf/templates/bookshelf/books.html
+4
-2
views.py
janang_reading/bookshelf/views.py
+6
-2
No files found.
janang_reading/bookshelf/__pycache__/views.cpython-310.pyc
View file @
b9e8b471
No preview for this file type
janang_reading/bookshelf/templates/bookshelf/authors.html
View file @
b9e8b471
...
@@ -5,9 +5,11 @@
...
@@ -5,9 +5,11 @@
{% block content %}
{% block content %}
{% block header %}
<h1>
{{ nickname }}'s Favorite Authors:
</h1>
{% endblock %}
{% block header %}
<h1>
{{ nickname }}'s Favorite Authors:
</h1>
{% endblock %}
<br>
<br>
{% for author in author
s
%}
{% for author in author
_data
%}
<a
href=
"/bookshelf/authors/{{ author.pk }}/details/"
>
{{ author.first_name }} {{ author.last_name }}
</a>
<a
href=
"/bookshelf/authors/{{ author.pk }}/details/"
>
{{ author.first_name }} {{ author.last_name }}
</a>
<br>
{% endfor %}
{% endfor %}
<br>
<br>
...
...
janang_reading/bookshelf/templates/bookshelf/books.html
View file @
b9e8b471
...
@@ -5,9 +5,11 @@
...
@@ -5,9 +5,11 @@
{% block content %}
{% block content %}
{% block header %}
<h1>
{{ nickname }}'s Favorite Books:
</h1>
{% endblock %}
{% block header %}
<h1>
{{ nickname }}'s Favorite Books:
</h1>
{% endblock %}
<br>
<br>
{% for book in books %}
{% for book in book_data %}
<a
href=
"/bookshelf/books/{{ book.pk }}/details/"
><p>
{{ book.title }}
</p></a>
<a
href=
"/bookshelf/books/{{ book.pk }}/details/"
>
{{ book.title }}
</a>
<br>
{% endfor %}
{% endfor %}
<br>
<br>
...
...
janang_reading/bookshelf/views.py
View file @
b9e8b471
...
@@ -12,18 +12,22 @@ def HomeView(request):
...
@@ -12,18 +12,22 @@ def HomeView(request):
class
AuthorView
(
ListView
):
class
AuthorView
(
ListView
):
def
get
(
self
,
request
):
def
get
(
self
,
request
):
model
=
Author
model
=
Author
return
render
(
request
,
'bookshelf/authors.html'
,
{
'nickname'
:
'Jan'
})
author_data
=
Author
.
objects
.
all
()
.
values
()
return
render
(
request
,
'bookshelf/authors.html'
,
{
'nickname'
:
'Jan'
,
'author_data'
:
author_data
})
class
AuthorDetailView
(
DetailView
):
class
AuthorDetailView
(
DetailView
):
model
=
Author
model
=
Author
model_data
=
Author
template_name
=
'bookshelf/author_details.html'
template_name
=
'bookshelf/author_details.html'
class
BooksView
(
ListView
):
class
BooksView
(
ListView
):
def
get
(
self
,
request
):
def
get
(
self
,
request
):
model
=
Books
model
=
Books
return
render
(
request
,
'bookshelf/books.html'
,
{
'nickname'
:
'Jan'
})
book_data
=
Books
.
objects
.
all
()
.
values
()
return
render
(
request
,
'bookshelf/books.html'
,
{
'nickname'
:
'Jan'
,
'book_data'
:
book_data
})
class
BookDetailView
(
DetailView
):
class
BookDetailView
(
DetailView
):
model
=
Books
model
=
Books
model_data
=
Books
template_name
=
'bookshelf/books_details.html'
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