Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
justinreyes_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
Justin Reyes
justinreyes_reading
Commits
b7610648
Commit
b7610648
authored
Apr 24, 2023
by
justin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: new book form functionality complete, redirects done
parent
02285178
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
4 deletions
+13
-4
views.cpython-310.pyc
...reyes_reading/bookshelf/__pycache__/views.cpython-310.pyc
+0
-0
add-book.html
...reyes_reading/bookshelf/templates/bookshelf/add-book.html
+1
-1
views.py
justinreyes_reading/bookshelf/views.py
+12
-3
db.sqlite3
justinreyes_reading/db.sqlite3
+0
-0
No files found.
justinreyes_reading/bookshelf/__pycache__/views.cpython-310.pyc
View file @
b7610648
No preview for this file type
justinreyes_reading/bookshelf/templates/bookshelf/add-book.html
View file @
b7610648
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
</ul>
</ul>
{% endif %}
{% endif %}
{% endfor %}
{% endfor %}
<form
action=
"/books/add"
method=
"post"
>
<form
action=
"/books/add"
method=
"post"
>
{% csrf_token %}
{% csrf_token %}
{{form}}
{{form}}
<input
type=
"submit"
value=
"Submit"
/>
<input
type=
"submit"
value=
"Submit"
/>
...
...
justinreyes_reading/bookshelf/views.py
View file @
b7610648
from
django.shortcuts
import
render
from
django.shortcuts
import
render
,
redirect
from
django.urls
import
reverse
from
django.views
import
View
from
django.views
import
View
from
django.views.generic.list
import
ListView
from
django.views.generic.list
import
ListView
from
django.views.generic.detail
import
DetailView
from
django.views.generic.detail
import
DetailView
...
@@ -14,8 +15,16 @@ def index(request):
...
@@ -14,8 +15,16 @@ def index(request):
def
add_book
(
request
):
def
add_book
(
request
):
form
=
BookForm
()
if
request
.
method
==
'POST'
:
return
render
(
request
,
"bookshelf/add-book.html"
,
{
"form"
:
form
})
form
=
BookForm
(
request
.
POST
)
if
form
.
is_valid
():
book
=
form
.
save
()
pk
=
book
.
pk
return
redirect
(
reverse
(
"book-detail"
,
args
=
[
pk
]))
else
:
form
=
BookForm
()
context
=
{
"form"
:
form
}
return
render
(
request
,
"bookshelf/add-book.html"
,
context
)
class
BookListView
(
ListView
):
class
BookListView
(
ListView
):
...
...
justinreyes_reading/db.sqlite3
View file @
b7610648
No preview for this file type
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