Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
calvincruz_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
Calvin Josh Cruz
calvincruz_reading
Commits
b5b638cc
Commit
b5b638cc
authored
Apr 25, 2023
by
karin-kurusu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Created "Add New Author" page and implemented it via ModelForm
parent
0ed1c915
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
28 additions
and
2 deletions
+28
-2
urls.cpython-310.pyc
...incruz_reading/bookshelf/__pycache__/urls.cpython-310.pyc
+0
-0
views.cpython-310.pyc
...ncruz_reading/bookshelf/__pycache__/views.cpython-310.pyc
+0
-0
forms.py
calvincruz_reading/bookshelf/forms.py
+6
-1
add-author.html
...ruz_reading/bookshelf/templates/bookshelf/add-author.html
+10
-0
urls.py
calvincruz_reading/bookshelf/urls.py
+2
-1
views.py
calvincruz_reading/bookshelf/views.py
+10
-0
db.sqlite3
calvincruz_reading/db.sqlite3
+0
-0
No files found.
calvincruz_reading/bookshelf/__pycache__/urls.cpython-310.pyc
View file @
b5b638cc
No preview for this file type
calvincruz_reading/bookshelf/__pycache__/views.cpython-310.pyc
View file @
b5b638cc
No preview for this file type
calvincruz_reading/bookshelf/forms.py
View file @
b5b638cc
from
django
import
forms
from
.models
import
Books
from
.models
import
Books
,
Author
class
BooksForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
Books
fields
=
[
'title'
,
'author'
,
'publisher'
,
'year_published'
,
'ISBN'
,
'blurb'
]
class
AuthorForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
Author
fields
=
[
'first_name'
,
'last_name'
,
'age'
,
'nationality'
,
'bio'
]
\ No newline at end of file
calvincruz_reading/bookshelf/templates/bookshelf/add-author.html
0 → 100644
View file @
b5b638cc
{% 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 %}
\ No newline at end of file
calvincruz_reading/bookshelf/urls.py
View file @
b5b638cc
from
django.urls
import
path
from
.views
import
home
,
BooksList
,
BooksDetails
,
AuthorList
,
AuthorDetails
,
BooksCreate
from
.views
import
home
,
BooksList
,
BooksDetails
,
AuthorList
,
AuthorDetails
,
BooksCreate
,
AuthorCreate
urlpatterns
=
[
path
(
'home/'
,
home
,
name
=
'home'
),
...
...
@@ -8,6 +8,7 @@ urlpatterns = [
path
(
'books/add'
,
BooksCreate
.
as_view
(),
name
=
'add-book'
),
path
(
'authors/'
,
AuthorList
.
as_view
(),
name
=
"authors"
),
path
(
'authors/<int:pk>/details'
,
AuthorDetails
.
as_view
(),
name
=
'author_details'
),
path
(
'authors/add'
,
AuthorCreate
.
as_view
(),
name
=
'add-author'
),
]
app_name
=
"bookshelf"
\ No newline at end of file
calvincruz_reading/bookshelf/views.py
View file @
b5b638cc
...
...
@@ -29,6 +29,16 @@ class BooksUpdate(UpdateView):
fields
=
'__all__'
template_name
=
'bookshelf/add-book.html'
class
AuthorCreate
(
CreateView
):
model
=
Author
fields
=
'__all__'
template_name
=
'bookshelf/add-author.html'
class
AuthorUpdate
(
UpdateView
):
model
=
Author
fields
=
'__all__'
template_name
=
'bookshelf/add-author.html'
class
AuthorList
(
ListView
):
def
get
(
self
,
request
):
author_list
=
Author
.
objects
.
all
()
...
...
calvincruz_reading/db.sqlite3
View file @
b5b638cc
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