Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
neilocampo_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
Christianneil Emmanuel Ocampo
neilocampo_reading
Commits
91b66e4a
Commit
91b66e4a
authored
Apr 25, 2023
by
Christianneil Emmanuel Ocampo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Created edit and add pages for books and authors
parent
ef3ab0fc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
6 deletions
+32
-6
urls.py
neilocampo_reading/bookshelf/urls.py
+8
-1
views.py
neilocampo_reading/bookshelf/views.py
+24
-5
No files found.
neilocampo_reading/bookshelf/urls.py
View file @
91b66e4a
from
django.urls
import
path
from
.views
import
home
,
AuthorsView
,
AuthorDetailsView
,
BooksView
,
BookDetailsView
from
.views
import
(
home
,
AuthorsView
,
AuthorDetailsView
,
BooksView
,
BookDetailsView
,
AuthorsCreateView
,
AuthorsUpdateView
,
BooksCreateView
,
BooksUpdateView
)
urlpatterns
=
[
path
(
'home/'
,
home
,
name
=
'home'
),
path
(
'authors/'
,
AuthorsView
.
as_view
(),
name
=
'author-list'
),
path
(
'author/<int:pk>/details/'
,
AuthorDetailsView
.
as_view
(),
name
=
'author-details'
),
path
(
'books/add/'
,
BooksCreateView
.
as_view
(),
name
=
'add-book'
),
path
(
'books/<int:pk>/edit/'
,
BooksUpdateView
.
as_view
(),
name
=
'update-book'
),
path
(
'books/'
,
BooksView
.
as_view
(),
name
=
'book-list'
),
path
(
'book/<int:pk>/details/'
,
BookDetailsView
.
as_view
(),
name
=
'book-details'
),
path
(
'authors/add/'
,
AuthorsCreateView
.
as_view
(),
name
=
'add-author'
),
path
(
'authors/<int:pk>/edit/'
,
AuthorsUpdateView
.
as_view
(),
name
=
'update-author'
),
]
app_name
=
"bookshelf"
\ No newline at end of file
neilocampo_reading/bookshelf/views.py
View file @
91b66e4a
from
django.shortcuts
import
render
from
django.views.generic.detail
import
DetailView
from
django.views.generic.list
import
ListView
from
django.views.generic.edit
import
CreateView
,
UpdateView
from
.models
import
Author
,
Book
def
home
(
request
):
...
...
@@ -11,17 +11,36 @@ class AuthorsView(ListView):
model
=
Author
template_name
=
'bookshelf/authors.html'
class
BooksView
(
ListView
):
model
=
Book
template_name
=
'bookshelf/books.html'
class
AuthorDetailsView
(
DetailView
):
model
=
Author
template_name
=
'bookshelf/author_details.html'
class
BookDetailsView
(
DetailView
):
model
=
Book
template_name
=
'bookshelf/book_details.html'
\ No newline at end of file
template_name
=
'bookshelf/book_details.html'
class
AuthorsCreateView
(
CreateView
):
model
=
Author
fields
=
'__all__'
template_name
=
"bookshelf/add-author.html"
class
BooksCreateView
(
CreateView
):
model
=
Book
fields
=
'__all__'
template_name
=
"bookshelf/add-book.html"
class
AuthorsUpdateView
(
UpdateView
):
model
=
Author
fields
=
'__all__'
template_name
=
"bookshelf/edit-author.html"
class
BooksUpdateView
(
UpdateView
):
model
=
Book
fields
=
'__all__'
template_name
=
"bookshelf/edit-book.html"
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