Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
joshbenito_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
Matthew Josh Benedict Benito
joshbenito_reading
Commits
8eddef72
Commit
8eddef72
authored
May 20, 2023
by
MJoshBen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented Add Author and Updated Homepage Links
parent
7a0f156f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
2 deletions
+21
-2
add-author.html
...ito_reading/bookshelf/templates/bookshelf/add-author.html
+13
-0
home.html
joshbenito_reading/bookshelf/templates/bookshelf/home.html
+1
-0
urls.py
joshbenito_reading/bookshelf/urls.py
+2
-1
views.py
joshbenito_reading/bookshelf/views.py
+5
-1
No files found.
joshbenito_reading/bookshelf/templates/bookshelf/add-author.html
View file @
8eddef72
{% extends 'base.html' %}
{% block title %}Add New Author{% endblock %}
{% block content %}
<form
action=
""
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"Add Author"
>
</form>
{% endblock %}
{% block scripts %}
{% endblock %}
joshbenito_reading/bookshelf/templates/bookshelf/home.html
View file @
8eddef72
...
@@ -17,4 +17,5 @@
...
@@ -17,4 +17,5 @@
<a
href=
"/books"
>
Books
</a>
<a
href=
"/books"
>
Books
</a>
<a
href=
"/authors"
>
Authors
</a><br>
<a
href=
"/authors"
>
Authors
</a><br>
<a
href=
"/books/add"
>
Add Book
</a>
<a
href=
"/books/add"
>
Add Book
</a>
<a
href=
"/authors/add"
>
Add Author
</a>
{% endblock %}
{% endblock %}
joshbenito_reading/bookshelf/urls.py
View file @
8eddef72
from
django.urls
import
path
from
django.urls
import
path
from
.views
import
homepage_view
,
BooksListView
,
BooksDetailView
,
BooksCreateView
,
AuthorListView
,
AuthorDetailView
from
.views
import
homepage_view
,
BooksListView
,
BooksDetailView
,
BooksCreateView
,
AuthorListView
,
AuthorDetailView
,
AuthorCreateView
urlpatterns
=
[
urlpatterns
=
[
path
(
'home/'
,
homepage_view
,
name
=
'home'
),
path
(
'home/'
,
homepage_view
,
name
=
'home'
),
...
@@ -9,6 +9,7 @@ urlpatterns = [
...
@@ -9,6 +9,7 @@ urlpatterns = [
path
(
'books/add/'
,
BooksCreateView
.
as_view
(),
name
=
'add-book'
),
path
(
'books/add/'
,
BooksCreateView
.
as_view
(),
name
=
'add-book'
),
path
(
'authors/'
,
AuthorListView
.
as_view
(),
name
=
'authors-list'
),
path
(
'authors/'
,
AuthorListView
.
as_view
(),
name
=
'authors-list'
),
path
(
'authors/<int:pk>/details'
,
AuthorDetailView
.
as_view
(),
name
=
'author-details'
),
path
(
'authors/<int:pk>/details'
,
AuthorDetailView
.
as_view
(),
name
=
'author-details'
),
path
(
'authors/add/'
,
AuthorCreateView
.
as_view
(),
name
=
'add-author'
)
]
]
app_name
=
"bookshelf"
app_name
=
"bookshelf"
joshbenito_reading/bookshelf/views.py
View file @
8eddef72
...
@@ -37,6 +37,10 @@ class AuthorDetailView(DetailView):
...
@@ -37,6 +37,10 @@ class AuthorDetailView(DetailView):
model
=
Author
model
=
Author
def
get
(
self
,
request
,
pk
):
def
get
(
self
,
request
,
pk
):
return
render
(
request
,
'bookshelf/author_details.html'
,
{
'author'
:
self
.
model
.
objects
.
get
(
pk
=
pk
)})
return
render
(
request
,
'bookshelf/author_details.html'
,
{
'author'
:
self
.
model
.
objects
.
get
(
pk
=
pk
)})
class
AuthorCreateView
(
CreateView
):
model
=
Author
fields
=
'__all__'
template_name
=
'bookshelf/add-author.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