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
7e5a802f
Commit
7e5a802f
authored
Apr 25, 2023
by
KaoruSawade
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented adding books: created add-book.html & edited urls.py and views.py
parent
3f3419f3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
3 deletions
+21
-3
add-book.html
...oarde_reading/bookshelf/templates/bookshelf/add-book.html
+11
-0
urls.py
carlosoarde_reading/bookshelf/urls.py
+3
-2
views.py
carlosoarde_reading/bookshelf/views.py
+7
-1
db.sqlite3
carlosoarde_reading/db.sqlite3
+0
-0
No files found.
carlosoarde_reading/bookshelf/templates/bookshelf/add-book.html
0 → 100644
View file @
7e5a802f
{% extends 'base.html' %}
{% load static %}
{% block title %}Add New Book{% endblock %}
{% block content %}
<form
action=
''
method=
"POST"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"Add Book"
>
</form>
{% endblock %}
carlosoarde_reading/bookshelf/urls.py
View file @
7e5a802f
from
django.urls
import
path
from
django.urls
import
path
from
.views
import
home
,
AuthorListView
,
AuthorDetailView
,
BooksListView
,
BooksDetailView
from
.views
import
home
,
AuthorListView
,
AuthorDetailView
,
BooksListView
,
BooksDetailView
,
BooksCreateView
urlpatterns
=
[
urlpatterns
=
[
path
(
'home/'
,
home
,
name
=
'home'
),
path
(
'home/'
,
home
,
name
=
'home'
),
...
@@ -7,6 +7,7 @@ urlpatterns = [
...
@@ -7,6 +7,7 @@ urlpatterns = [
path
(
'authors/<int:pk>/details'
,
AuthorDetailView
.
as_view
(),
name
=
'author-detail'
),
path
(
'authors/<int:pk>/details'
,
AuthorDetailView
.
as_view
(),
name
=
'author-detail'
),
path
(
'books/'
,
BooksListView
.
as_view
(),
name
=
'books-list'
),
path
(
'books/'
,
BooksListView
.
as_view
(),
name
=
'books-list'
),
path
(
'books/<int:pk>/details'
,
BooksDetailView
.
as_view
(),
name
=
'books-detail'
),
path
(
'books/<int:pk>/details'
,
BooksDetailView
.
as_view
(),
name
=
'books-detail'
),
]
path
(
'books/add'
,
BooksCreateView
.
as_view
(),
name
=
'add-book'
),
]
app_name
=
"bookshelf"
app_name
=
"bookshelf"
carlosoarde_reading/bookshelf/views.py
View file @
7e5a802f
...
@@ -2,6 +2,7 @@ from django.shortcuts import render
...
@@ -2,6 +2,7 @@ from django.shortcuts import render
from
django.views
import
View
from
django.views
import
View
from
django.views.generic.detail
import
DetailView
from
django.views.generic.detail
import
DetailView
from
django.views.generic.list
import
ListView
from
django.views.generic.list
import
ListView
from
django.views.generic.edit
import
CreateView
,
UpdateView
from
.models
import
Author
,
Books
from
.models
import
Author
,
Books
def
home
(
request
):
def
home
(
request
):
...
@@ -27,4 +28,9 @@ class BooksDetailView(DetailView):
...
@@ -27,4 +28,9 @@ class BooksDetailView(DetailView):
def
get
(
self
,
request
,
pk
):
def
get
(
self
,
request
,
pk
):
book
=
Books
.
objects
.
get
(
pk
=
pk
)
book
=
Books
.
objects
.
get
(
pk
=
pk
)
author
=
book
.
author
author
=
book
.
author
return
render
(
request
,
'bookshelf/books_detail.html'
,
{
'author'
:
author
,
'book'
:
book
})
return
render
(
request
,
'bookshelf/books_detail.html'
,
{
'author'
:
author
,
'book'
:
book
})
\ No newline at end of file
class
BooksCreateView
(
CreateView
):
model
=
Books
fields
=
'__all__'
template_name
=
'bookshelf/add-book.html'
\ No newline at end of file
carlosoarde_reading/db.sqlite3
View file @
7e5a802f
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