Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
Deokhyun_Lee_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
Deokhyun Lee
Deokhyun_Lee_reading
Commits
f02aa6b0
Commit
f02aa6b0
authored
Apr 25, 2023
by
Deokhyun Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
edit-author html can be accessed correctly and updating and redirecting works as intended.
parent
174b4b97
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
4 deletions
+19
-4
urls.py
Deokhyun_Lee_reading/bookshelf/urls.py
+2
-2
views.py
Deokhyun_Lee_reading/bookshelf/views.py
+17
-2
No files found.
Deokhyun_Lee_reading/bookshelf/urls.py
View file @
f02aa6b0
from
django.urls
import
path
from
.views
import
HomeView
,
AuthorListView
,
AuthorDetailView
,
AuthorAddListView
,
BookListView
,
BookDetailView
,
BookAddListView
,
BookEditView
from
.views
import
HomeView
,
AuthorListView
,
AuthorDetailView
,
AuthorAddListView
,
AuthorEditView
,
BookListView
,
BookDetailView
,
BookAddListView
,
BookEditView
urlpatterns
=
[
# for Home (landing page)
...
...
@@ -8,7 +8,7 @@ urlpatterns = [
path
(
'authors/'
,
AuthorListView
.
as_view
(),
name
=
'authors'
),
path
(
'authors/<int:pk>/details'
,
AuthorDetailView
.
as_view
(),
name
=
'author_detail'
),
path
(
'authors/add'
,
AuthorAddListView
.
as_view
(),
name
=
"add_author"
),
path
(
'authors/<int:pk>/edit'
,
AuthorEditView
.
as_view
(),
name
=
'author_edit'
),
# for Books page
path
(
'books/'
,
BookListView
.
as_view
(),
name
=
'books'
),
path
(
'books/<int:pk>/details'
,
BookDetailView
.
as_view
(),
name
=
'book_detail'
),
...
...
Deokhyun_Lee_reading/bookshelf/views.py
View file @
f02aa6b0
...
...
@@ -66,9 +66,9 @@ class BookEditView(UpdateView):
form
=
AddBookForm
(
request
.
POST
)
if
form
.
is_valid
():
# onSave is called, the form will have essential data and this includes pk as well.
new
_book
=
form
.
save
()
update
_book
=
form
.
save
()
# pass the pk and redirect.
return
redirect
(
'book_detail'
,
pk
=
new
_book
.
pk
)
return
redirect
(
'book_detail'
,
pk
=
update
_book
.
pk
)
else
:
return
render
(
request
,
'book_details.html'
,
{
'form'
:
form
})
...
...
@@ -86,5 +86,20 @@ class AuthorAddListView(CreateView):
new_author
=
form
.
save
()
# pass the pk and redirect.
return
redirect
(
'author_detail'
,
pk
=
new_author
.
pk
)
else
:
return
render
(
request
,
'author_details.html'
,
{
'form'
:
form
})
class
AuthorEditView
(
UpdateView
):
model
=
Author
form_class
=
AddAuthorForm
template_name
=
'authors/edit-author.html'
def
post
(
self
,
request
,
pk
):
form
=
AddAuthorForm
(
request
.
POST
)
if
form
.
is_valid
():
# onSave is called, the form will have essential data and this includes pk as well.
update_author
=
form
.
save
()
# pass the pk and redirect.
return
redirect
(
'author_detail'
,
pk
=
update_author
.
pk
)
else
:
return
render
(
request
,
'author_details.html'
,
{
'form'
:
form
})
\ 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