Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
carlosoarde_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
Carlos Gabriel Oarde
carlosoarde_reading
Commits
79e44495
Commit
79e44495
authored
Mar 28, 2023
by
KaoruSawade
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated views.py and urls.py to implement books page and per book page via CBV
parent
6d916cf2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
2 deletions
+14
-2
urls.cpython-311.pyc
...soarde_reading/bookshelf/__pycache__/urls.cpython-311.pyc
+0
-0
views.cpython-311.pyc
...oarde_reading/bookshelf/__pycache__/views.cpython-311.pyc
+0
-0
urls.py
carlosoarde_reading/bookshelf/urls.py
+3
-1
views.py
carlosoarde_reading/bookshelf/views.py
+11
-1
No files found.
carlosoarde_reading/bookshelf/__pycache__/urls.cpython-311.pyc
View file @
79e44495
No preview for this file type
carlosoarde_reading/bookshelf/__pycache__/views.cpython-311.pyc
View file @
79e44495
No preview for this file type
carlosoarde_reading/bookshelf/urls.py
View file @
79e44495
from
django.urls
import
path
from
django.urls
import
path
from
.views
import
home
,
AuthorListView
,
AuthorDetailView
from
.views
import
home
,
AuthorListView
,
AuthorDetailView
,
BooksListView
,
BooksDetailView
urlpatterns
=
[
urlpatterns
=
[
path
(
'home/'
,
home
,
name
=
'home'
),
path
(
'home/'
,
home
,
name
=
'home'
),
path
(
'authors/'
,
AuthorListView
.
as_view
(),
name
=
'author-list'
),
path
(
'authors/'
,
AuthorListView
.
as_view
(),
name
=
'author-list'
),
path
(
'authors/<int:pk>/details'
,
AuthorDetailView
.
as_view
(),
name
=
'author-detail'
),
path
(
'authors/<int:pk>/details'
,
AuthorDetailView
.
as_view
(),
name
=
'author-detail'
),
path
(
'books/'
,
BooksListView
.
as_view
(),
name
=
'books-list'
),
path
(
'books/<int:pk>/details'
,
BooksDetailView
.
as_view
(),
name
=
'books-detail'
),
]
]
app_name
=
"bookshelf"
app_name
=
"bookshelf"
carlosoarde_reading/bookshelf/views.py
View file @
79e44495
...
@@ -16,5 +16,15 @@ class AuthorDetailView(DetailView):
...
@@ -16,5 +16,15 @@ class AuthorDetailView(DetailView):
def
get
(
self
,
request
,
pk
):
def
get
(
self
,
request
,
pk
):
author
=
Author
.
objects
.
get
(
pk
=
pk
)
author
=
Author
.
objects
.
get
(
pk
=
pk
)
book_list
=
Books
.
objects
.
filter
(
author__first_name__exact
=
author
.
first_name
)
book_list
=
Books
.
objects
.
filter
(
author__first_name__exact
=
author
.
first_name
)
return
render
(
request
,
'bookshelf/author_detail.html'
,
{
'author'
:
author
,
'book_list'
:
book_list
})
class
BooksListView
(
ListView
):
def
get
(
self
,
request
):
books_list
=
Books
.
objects
.
all
()
return
render
(
request
,
'bookshelf/books_list.html'
,
{
'name'
:
'Carlos'
,
'books_list'
:
books_list
})
return
render
(
request
,
'bookshelf/author_detail.html'
,
{
'author'
:
author
,
'book_list'
:
book_list
})
class
BooksDetailView
(
DetailView
):
\ No newline at end of file
def
get
(
self
,
request
,
pk
):
book
=
Books
.
objects
.
get
(
pk
=
pk
)
author
=
book
.
author
return
render
(
request
,
'bookshelf/books_detail.html'
,
{
'author'
:
author
,
'book'
:
book
})
\ 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