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
0ed1c915
Commit
0ed1c915
authored
Apr 25, 2023
by
karin-kurusu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Created "Add New Book" page and implemented it via ModelForm
parent
8cb4706e
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
37 additions
and
1 deletion
+37
-1
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
+7
-0
add-book.html
...ncruz_reading/bookshelf/templates/bookshelf/add-book.html
+11
-0
home.html
calvincruz_reading/bookshelf/templates/home.html
+6
-0
urls.py
calvincruz_reading/bookshelf/urls.py
+2
-1
views.py
calvincruz_reading/bookshelf/views.py
+11
-0
db.sqlite3
calvincruz_reading/db.sqlite3
+0
-0
No files found.
calvincruz_reading/bookshelf/__pycache__/urls.cpython-310.pyc
View file @
0ed1c915
No preview for this file type
calvincruz_reading/bookshelf/__pycache__/views.cpython-310.pyc
View file @
0ed1c915
No preview for this file type
calvincruz_reading/bookshelf/forms.py
0 → 100644
View file @
0ed1c915
from
django
import
forms
from
.models
import
Books
class
BooksForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
Books
fields
=
[
'title'
,
'author'
,
'publisher'
,
'year_published'
,
'ISBN'
,
'blurb'
]
calvincruz_reading/bookshelf/templates/bookshelf/add-book.html
0 → 100644
View file @
0ed1c915
{% 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 %}
\ No newline at end of file
calvincruz_reading/bookshelf/templates/home.html
View file @
0ed1c915
...
@@ -22,4 +22,10 @@
...
@@ -22,4 +22,10 @@
<li
class=
"navbarItem"
><a
href=
"/books"
>
Books
</a></li>
<li
class=
"navbarItem"
><a
href=
"/books"
>
Books
</a></li>
<li
class=
"navbarItem"
><a
href=
"/authors"
>
Authors
</a></li>
<li
class=
"navbarItem"
><a
href=
"/authors"
>
Authors
</a></li>
</ul>
</ul>
<ul
class=
"navbarList"
>
<li
class=
"navbarItem"
><a
href=
"/books/add"
>
Add Book
</a></li>
<li
class=
"navbarItem"
><a
href=
"/authors/add"
>
Add Author
</a></li>
</ul>
{% endblock %}
{% endblock %}
\ No newline at end of file
calvincruz_reading/bookshelf/urls.py
View file @
0ed1c915
from
django.urls
import
path
from
django.urls
import
path
from
.views
import
home
,
BooksList
,
BooksDetails
,
AuthorList
,
AuthorDetails
from
.views
import
home
,
BooksList
,
BooksDetails
,
AuthorList
,
AuthorDetails
,
BooksCreate
urlpatterns
=
[
urlpatterns
=
[
path
(
'home/'
,
home
,
name
=
'home'
),
path
(
'home/'
,
home
,
name
=
'home'
),
path
(
'books/'
,
BooksList
.
as_view
(),
name
=
'books'
),
path
(
'books/'
,
BooksList
.
as_view
(),
name
=
'books'
),
path
(
'books/<int:pk>/details'
,
BooksDetails
.
as_view
(),
name
=
'book_detais'
),
path
(
'books/<int:pk>/details'
,
BooksDetails
.
as_view
(),
name
=
'book_detais'
),
path
(
'books/add'
,
BooksCreate
.
as_view
(),
name
=
'add-book'
),
path
(
'authors/'
,
AuthorList
.
as_view
(),
name
=
"authors"
),
path
(
'authors/'
,
AuthorList
.
as_view
(),
name
=
"authors"
),
path
(
'authors/<int:pk>/details'
,
AuthorDetails
.
as_view
(),
name
=
'author_details'
),
path
(
'authors/<int:pk>/details'
,
AuthorDetails
.
as_view
(),
name
=
'author_details'
),
]
]
...
...
calvincruz_reading/bookshelf/views.py
View file @
0ed1c915
...
@@ -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.list
import
ListView
from
django.views.generic.list
import
ListView
from
django.views.generic.detail
import
DetailView
from
django.views.generic.detail
import
DetailView
from
django.views.generic.edit
import
CreateView
,
UpdateView
from
.models
import
Author
,
Books
from
.models
import
Author
,
Books
def
home
(
request
):
def
home
(
request
):
...
@@ -18,6 +19,16 @@ class BooksDetails(DetailView):
...
@@ -18,6 +19,16 @@ class BooksDetails(DetailView):
author
=
book
.
author
author
=
book
.
author
return
render
(
request
,
'bookshelf/book_detais.html'
,
{
'author'
:
author
,
'book'
:
book
})
return
render
(
request
,
'bookshelf/book_detais.html'
,
{
'author'
:
author
,
'book'
:
book
})
class
BooksCreate
(
CreateView
):
model
=
Books
fields
=
'__all__'
template_name
=
'bookshelf/add-book.html'
class
BooksUpdate
(
UpdateView
):
model
=
Books
fields
=
'__all__'
template_name
=
'bookshelf/add-book.html'
class
AuthorList
(
ListView
):
class
AuthorList
(
ListView
):
def
get
(
self
,
request
):
def
get
(
self
,
request
):
author_list
=
Author
.
objects
.
all
()
author_list
=
Author
.
objects
.
all
()
...
...
calvincruz_reading/db.sqlite3
View file @
0ed1c915
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