Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
joeiyucoco_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
Joei Yucoco
joeiyucoco_reading
Commits
fb4cf22b
Commit
fb4cf22b
authored
Apr 24, 2023
by
Joei Yucoco
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added working books/add/ url
parent
733e2684
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
25 additions
and
4 deletions
+25
-4
urls.cpython-39.pyc
joeiyucoco_reading/bookshelf/__pycache__/urls.cpython-39.pyc
+0
-0
views.cpython-39.pyc
...yucoco_reading/bookshelf/__pycache__/views.cpython-39.pyc
+0
-0
.DS_Store
joeiyucoco_reading/bookshelf/templates/bookshelf/.DS_Store
+0
-0
book_add.html
...ucoco_reading/bookshelf/templates/bookshelf/book_add.html
+10
-0
urls.py
joeiyucoco_reading/bookshelf/urls.py
+3
-1
views.py
joeiyucoco_reading/bookshelf/views.py
+12
-3
db.sqlite3
joeiyucoco_reading/db.sqlite3
+0
-0
No files found.
joeiyucoco_reading/bookshelf/__pycache__/urls.cpython-39.pyc
View file @
fb4cf22b
No preview for this file type
joeiyucoco_reading/bookshelf/__pycache__/views.cpython-39.pyc
View file @
fb4cf22b
No preview for this file type
joeiyucoco_reading/bookshelf/templates/bookshelf/.DS_Store
View file @
fb4cf22b
No preview for this file type
joeiyucoco_reading/bookshelf/templates/bookshelf/book_add.html
0 → 100644
View file @
fb4cf22b
<!DOCTYPE html>
{% extends 'base.html' %}
{% block title %}My Favorite Authors{% endblock %}
{% block content %}
<form
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"Add Book"
>
</form>
{% endblock %}
joeiyucoco_reading/bookshelf/urls.py
View file @
fb4cf22b
from
django.urls
import
path
from
django.urls
import
path
from
.views
import
HomeView
,
BooksView
,
BookDetailsView
,
AuthorsView
,
AuthorDetailsView
,
AuthorAddView
from
.views
import
(
HomeView
,
BooksView
,
BookDetailsView
,
AuthorsView
,
AuthorDetailsView
,
AuthorAddView
,
BookAddView
)
urlpatterns
=
[
urlpatterns
=
[
path
(
'home/'
,
HomeView
,
name
=
'home'
),
path
(
'home/'
,
HomeView
,
name
=
'home'
),
...
@@ -8,6 +9,7 @@ urlpatterns = [
...
@@ -8,6 +9,7 @@ urlpatterns = [
path
(
'authors/'
,
AuthorsView
.
as_view
(),
name
=
'authors-list'
),
path
(
'authors/'
,
AuthorsView
.
as_view
(),
name
=
'authors-list'
),
path
(
'authors/<int:pk>/details/'
,
AuthorDetailsView
.
as_view
(),
name
=
'authors-detail'
),
path
(
'authors/<int:pk>/details/'
,
AuthorDetailsView
.
as_view
(),
name
=
'authors-detail'
),
path
(
'authors/add/'
,
AuthorAddView
,
name
=
'authors-add'
),
path
(
'authors/add/'
,
AuthorAddView
,
name
=
'authors-add'
),
path
(
'books/add/'
,
BookAddView
,
name
=
'books-add'
),
]
]
app_name
=
"bookshelf"
app_name
=
"bookshelf"
joeiyucoco_reading/bookshelf/views.py
View file @
fb4cf22b
...
@@ -34,15 +34,24 @@ class AuthorDetailsView(DetailView):
...
@@ -34,15 +34,24 @@ class AuthorDetailsView(DetailView):
#TODO: add template, app urls,
#TODO: add template, app urls,
def
AuthorAddView
(
request
):
def
AuthorAddView
(
request
):
#context ={}
if
request
.
method
==
'POST'
:
if
request
.
method
==
'POST'
:
form
=
AuthorForm
(
request
.
POST
)
form
=
AuthorForm
(
request
.
POST
)
if
form
.
is_valid
():
if
form
.
is_valid
():
new_author
=
form
.
save
()
new_author
=
form
.
save
()
#context['form']= form
return
redirect
(
'bookshelf:authors-detail'
,
pk
=
new_author
.
pk
)
return
redirect
(
'bookshelf:authors-detail'
,
pk
=
new_author
.
pk
)
else
:
else
:
form
=
AuthorForm
()
form
=
AuthorForm
()
return
render
(
request
,
'bookshelf/author_add.html'
,
{
'form'
:
form
})
return
render
(
request
,
'bookshelf/author_add.html'
,
{
'form'
:
form
})
def
BookAddView
(
request
):
if
request
.
method
==
'POST'
:
form
=
BooksForm
(
request
.
POST
)
if
form
.
is_valid
():
new_book
=
form
.
save
()
return
redirect
(
'bookshelf:books-detail'
,
pk
=
new_book
.
pk
)
else
:
form
=
BooksForm
()
return
render
(
request
,
'bookshelf/book_add.html'
,
{
'form'
:
form
})
joeiyucoco_reading/db.sqlite3
View file @
fb4cf22b
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