Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
carlosoarde_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
Carlos Gabriel Oarde
carlosoarde_reading
Commits
67815043
Commit
67815043
authored
Apr 25, 2023
by
KaoruSawade
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented adding authors: created add-author.html & edited urls.py and views.py
parent
7e5a802f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
2 deletions
+19
-2
add-author.html
...rde_reading/bookshelf/templates/bookshelf/add-author.html
+11
-0
urls.py
carlosoarde_reading/bookshelf/urls.py
+2
-1
views.py
carlosoarde_reading/bookshelf/views.py
+6
-1
db.sqlite3
carlosoarde_reading/db.sqlite3
+0
-0
No files found.
carlosoarde_reading/bookshelf/templates/bookshelf/add-author.html
0 → 100644
View file @
67815043
{% extends 'base.html' %}
{% load static %}
{% 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 %}
carlosoarde_reading/bookshelf/urls.py
View file @
67815043
from
django.urls
import
path
from
.views
import
home
,
AuthorListView
,
AuthorDetailView
,
BooksListView
,
BooksDetailView
,
BooksCreateView
from
.views
import
home
,
AuthorListView
,
AuthorDetailView
,
AuthorCreateView
,
BooksListView
,
BooksDetailView
,
BooksCreateView
urlpatterns
=
[
path
(
'home/'
,
home
,
name
=
'home'
),
path
(
'authors/'
,
AuthorListView
.
as_view
(),
name
=
'author-list'
),
path
(
'authors/<int:pk>/details'
,
AuthorDetailView
.
as_view
(),
name
=
'author-detail'
),
path
(
'authors/add'
,
AuthorCreateView
.
as_view
(),
name
=
'add-book'
),
path
(
'books/'
,
BooksListView
.
as_view
(),
name
=
'books-list'
),
path
(
'books/<int:pk>/details'
,
BooksDetailView
.
as_view
(),
name
=
'books-detail'
),
path
(
'books/add'
,
BooksCreateView
.
as_view
(),
name
=
'add-book'
),
...
...
carlosoarde_reading/bookshelf/views.py
View file @
67815043
...
...
@@ -18,7 +18,12 @@ class AuthorDetailView(DetailView):
author
=
Author
.
objects
.
get
(
pk
=
pk
)
book_list
=
Books
.
objects
.
filter
(
author__first_name__exact
=
author
.
first_name
)
return
render
(
request
,
'bookshelf/author_detail.html'
,
{
'author'
:
author
,
'book_list'
:
book_list
})
class
AuthorCreateView
(
CreateView
):
model
=
Author
fields
=
'__all__'
template_name
=
'bookshelf/add-author.html'
class
BooksListView
(
ListView
):
def
get
(
self
,
request
):
books_list
=
Books
.
objects
.
all
()
...
...
carlosoarde_reading/db.sqlite3
View file @
67815043
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