Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jakhermosisima_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
Joaquin Hermosisima
jakhermosisima_reading
Commits
9cf75775
Commit
9cf75775
authored
Apr 13, 2023
by
Joaquin Hermosisima
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
edited views.py
parent
0a08ef79
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
1 deletion
+40
-1
views.py
jakhermosisima_reading/bookshelf/views.py
+40
-1
No files found.
jakhermosisima_reading/bookshelf/views.py
View file @
9cf75775
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
django.views.generic.list
import
ListView
from
django.views.generic.detail
import
DetailView
from
.models
import
Author
,
Book
class
BookListView
(
ListView
):
model
=
Book
template_name
=
'book_list.html'
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
()
.
get_context_data
(
**
kwargs
)
context
[
'title'
]
=
"My Favorite Books"
context
[
'nickname'
]
=
"Jak"
context
[
'url_list'
]
=
[
'home'
,
'authors'
]
return
context
class
BookDetailView
(
DetailView
):
model
=
Book
template_name
=
"bookshelf/book_details.html"
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
()
.
get_context_data
(
**
kwargs
)
context
[
'nickname'
]
=
"Jak"
context
[
'url_list'
]
=
[
'home'
,
'books'
,
'authors'
]
return
context
class
AuthorListView
(
ListView
):
model
=
Author
template_name
=
'bookshelf/author_list.html'
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
()
.
get_context_data
(
**
kwargs
)
context
[
'nickname'
]
=
"Jak"
context
[
'url_list'
]
=
[
'home'
,
'books'
]
return
context
class
AuthorDetailView
(
DetailView
):
model
=
Author
template_name
=
'bookshelf/author_details.html'
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
()
.
get_context_data
(
**
kwargs
)
context
[
'url_list'
]
=
[
'home'
,
'books'
,
'authors'
]
context
[
'book_list'
]
=
Book
.
objects
.
filter
(
author
=
self
.
object
.
pk
)
return
context
\ No newline at end of file
# Create your views here.
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