Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
fausto_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
Brendan Fausto
fausto_reading
Commits
c5c3a554
Commit
c5c3a554
authored
Apr 27, 2023
by
Brendan Fausto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added templates for adding data, modified views to accomodate
parent
12ecffad
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
89 additions
and
0 deletions
+89
-0
add-author.html
reading/bookshelf/templates/bookshelf/add-author.html
+38
-0
add-book.html
reading/bookshelf/templates/bookshelf/add-book.html
+37
-0
views.py
reading/bookshelf/views.py
+14
-0
No files found.
reading/bookshelf/templates/bookshelf/add-author.html
0 → 100644
View file @
c5c3a554
{% extends 'base.html' %}
{% block title %}
Add Author to Bookshelf
{% endblock %}
{% block header %}
<h1>
Add New Author
</h1>
{% endblock %}
{% block content %}
{{ form.non_field_errors }}
{% for field in form %}
{% if field.errors %}
<p>
{{ field.label }} has the following errors:
</p>
<ul>
{% for error in field.errors %}
<li>
{{ error }}
</li>
{% endfor %}
</ul>
{% endif %}
{% endfor %}
<form
method =
"POST"
>
{% csrf_token %}
{{ form.as_p }}
<input
type =
"submit"
value =
"Save"
>
</form>
<p>
<a
href =
"http://127.0.0.1:8000/home"
>
Home
</a>
<a
href =
"http://127.0.0.1:8000/books"
>
Books
</a>
<a
href =
"http://127.0.0.1:8000/authors"
>
Authors
</a>
</p>
{% endblock %}
\ No newline at end of file
reading/bookshelf/templates/bookshelf/add-book.html
0 → 100644
View file @
c5c3a554
{% extends 'base.html' %}
{% block title %}
Add Book to Bookshelf
{% endblock %}
{% block header %}
<h1>
Add New Book
</h1>
{% endblock %}
{% block content %}
{{ form.non_field_errors }}
{% for field in form %}
{% if field.errors %}
<p>
{{ field.label }} has the following errors:
</p>
<ul>
{% for error in field.errors %}
<li>
{{ error }}
</li>
{% endfor %}
</ul>
{% endif %}
{% endfor %}
<form
method =
"POST"
>
{% csrf_token %}
{{ form.as_p }}
<input
type =
"submit"
value =
"Save"
>
</form>
<p>
<a
href =
"http://127.0.0.1:8000/home"
>
Home
</a>
<a
href =
"http://127.0.0.1:8000/authors"
>
Authors
</a>
</p>
{% endblock %}
\ No newline at end of file
reading/bookshelf/views.py
View file @
c5c3a554
...
...
@@ -3,6 +3,7 @@ from django.views import View
from
django.views.generic.detail
import
DetailView
from
django.views.generic.list
import
ListView
from
django.shortcuts
import
get_object_or_404
from
django.views.generic.edit
import
CreateView
,
UpdateView
from
.models
import
Books
,
Authors
...
...
@@ -29,8 +30,21 @@ class BookDetailView(DetailView):
model
=
Books
template_name
=
'bookshelf/books_details.html'
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
print
(
"BooksDetailView is being called"
)
return
super
()
.
get
(
request
,
*
args
,
**
kwargs
)
class
AuthorDetailView
(
DetailView
):
model
=
Authors
template_name
=
'bookshelf/authors_details.html'
class
BookCreateView
(
CreateView
):
model
=
Books
fields
=
'__all__'
template_name
=
'add-book.html'
class
AuthorCreateView
(
CreateView
):
model
=
Books
fields
=
'__all__'
template_name
=
'add-book.html'
# Create your views here.
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