Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
elaizabolislis_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
Elaiza Bolislis
elaizabolislis_reading
Commits
ed8c0499
Commit
ed8c0499
authored
Apr 25, 2023
by
Elaiza Bolislis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Created two new pages that allow users to add new books and new authors into the database.
parent
7cfaff4c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
3 deletions
+42
-3
add-author.html
...lis_reading/bookshelf/templates/bookshelf/add-author.html
+12
-0
add-book.html
...islis_reading/bookshelf/templates/bookshelf/add-book.html
+12
-0
urls.py
elaizabolislis_reading/bookshelf/urls.py
+4
-2
views.py
elaizabolislis_reading/bookshelf/views.py
+14
-1
No files found.
elaizabolislis_reading/bookshelf/templates/bookshelf/add-author.html
0 → 100644
View file @
ed8c0499
{% extends 'base.html' %}
{% load static %}
{% block title %}Add New Author{% endblock %}
{% block content %}
<form
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"Add Author"
>
</form>
{% endblock %}
\ No newline at end of file
elaizabolislis_reading/bookshelf/templates/bookshelf/add-book.html
0 → 100644
View file @
ed8c0499
{% extends 'base.html' %}
{% load static %}
{% block title %}Add New Book{% endblock %}
{% block content %}
<form
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"Add Book"
>
</form>
{% endblock %}
\ No newline at end of file
elaizabolislis_reading/bookshelf/urls.py
View file @
ed8c0499
from
django.urls
import
path
from
.views
import
(
index
,
homepage
,
BooksListView
,
BooksDetailView
,
AuthorListView
,
AuthorDetailView
BooksListView
,
BooksDetailView
,
BooksCreateView
,
AuthorListView
,
AuthorDetailView
,
AuthorCreateView
)
urlpatterns
=
[
...
...
@@ -10,9 +10,11 @@ urlpatterns = [
path
(
'home'
,
homepage
,
name
=
'home'
),
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
=
'books-create'
),
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
=
'author-create'
),
]
app_name
=
"bookshelf"
elaizabolislis_reading/bookshelf/views.py
View file @
ed8c0499
from
django.shortcuts
import
render
from
django.shortcuts
import
render
,
redirect
from
django.http
import
HttpResponse
from
django.views
import
View
from
django.views.generic.list
import
ListView
from
django.views.generic.detail
import
DetailView
from
django.views.generic.edit
import
CreateView
,
UpdateView
from
.models
import
Author
,
Books
...
...
@@ -38,3 +39,15 @@ class AuthorDetailView(DetailView):
context
=
super
()
.
get_context_data
(
**
kwargs
)
context
[
'books'
]
=
Books
.
objects
.
all
()
return
context
class
BooksCreateView
(
CreateView
):
model
=
Books
fields
=
'__all__'
template_name
=
'bookshelf/add-book.html'
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