Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
joaqscrisologo_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
Joaquin Inigo Crisologo
joaqscrisologo_reading
Commits
b338ab23
Commit
b338ab23
authored
Apr 25, 2023
by
Joaquin Inigo Crisologo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add CreateView for adding Authors
parent
0d3709e9
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
33 additions
and
1 deletion
+33
-1
forms.cpython-39.pyc
...sologo_reading/bookshelf/__pycache__/forms.cpython-39.pyc
+0
-0
urls.cpython-39.pyc
...isologo_reading/bookshelf/__pycache__/urls.cpython-39.pyc
+0
-0
views.cpython-39.pyc
...sologo_reading/bookshelf/__pycache__/views.cpython-39.pyc
+0
-0
add-author.html
...ogo_reading/bookshelf/templates/bookshelf/add-author.html
+25
-0
urls.py
joaqscrisologo_reading/bookshelf/urls.py
+2
-1
views.py
joaqscrisologo_reading/bookshelf/views.py
+6
-0
db.sqlite3
joaqscrisologo_reading/db.sqlite3
+0
-0
No files found.
joaqscrisologo_reading/bookshelf/__pycache__/forms.cpython-39.pyc
0 → 100644
View file @
b338ab23
File added
joaqscrisologo_reading/bookshelf/__pycache__/urls.cpython-39.pyc
View file @
b338ab23
No preview for this file type
joaqscrisologo_reading/bookshelf/__pycache__/views.cpython-39.pyc
View file @
b338ab23
No preview for this file type
joaqscrisologo_reading/bookshelf/templates/bookshelf/add-author.html
0 → 100644
View file @
b338ab23
{% extends 'base.html' %}
{% load static %}
{% block title %} Add New Author {% 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 }}
<br>
<input
type=
"submit"
value=
"Add Author"
>
</form>
<br><hr>
{% endblock %}
\ No newline at end of file
joaqscrisologo_reading/bookshelf/urls.py
View file @
b338ab23
from
django.urls
import
path
from
.views
import
HomeView
,
AuthorListView
,
AuthorDetailView
,
BooksListView
,
BooksDetailView
from
.views
import
HomeView
,
AuthorListView
,
AuthorDetailView
,
BooksListView
,
BooksDetailView
,
AuthorCreateView
urlpatterns
=
[
path
(
''
,
HomeView
,
name
=
'index'
),
...
...
@@ -7,6 +7,7 @@ urlpatterns = [
path
(
'authors/<int:pk>/details'
,
AuthorDetailView
.
as_view
(),
name
=
'author-detail'
),
path
(
'books'
,
BooksListView
.
as_view
(),
name
=
'books-list'
),
path
(
'books/<int:pk>/details'
,
BooksDetailView
.
as_view
(),
name
=
'books-detail'
),
path
(
'authors/add'
,
AuthorCreateView
.
as_view
(),
name
=
'author-add'
),
]
# This might be needed, depending on your Django version
...
...
joaqscrisologo_reading/bookshelf/views.py
View file @
b338ab23
...
...
@@ -3,6 +3,7 @@ from django.http import HttpResponse
from
django.views
import
View
from
django.views.generic.detail
import
DetailView
from
django.views.generic.list
import
ListView
from
django.views.generic.edit
import
CreateView
,
UpdateView
from
.models
import
Author
,
Books
...
...
@@ -20,3 +21,8 @@ class BooksListView(ListView):
class
BooksDetailView
(
DetailView
):
model
=
Books
class
AuthorCreateView
(
CreateView
):
model
=
Author
fields
=
'__all__'
template_name
=
'bookshelf/add-author.html'
joaqscrisologo_reading/db.sqlite3
View file @
b338ab23
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