Commit a71efdd2 authored by Trisha Angel Millena's avatar Trisha Angel Millena

Edited urls.py: Added CreateView, Edited views.py: Added s to book, Edited...

Edited urls.py: Added CreateView, Edited views.py: Added s to book, Edited views.py: Added class AuthorCreateView
parent 0f07d739
......@@ -5,13 +5,10 @@
{% block title %}Add New Book{% endblock %}
{% block content %}
<form method = "POST">
{% csrf_token % }
{% csrf_token %}
{{ form.as_p }}
<input type = "submit" value = "Add Book" />
</form>
{% endblock %}
from django.urls import path
from .views import (
home, BooksListView, BooksDetailView, AuthorListView, AuthorDetailView
)
from .views import (home, BooksListView, BooksDetailView, AuthorListView, AuthorDetailView, BooksCreateView)
urlpatterns = [
path('home/', home, name = 'home'),
......@@ -10,7 +8,7 @@ urlpatterns = [
path('authors/', AuthorListView.as_view(), name = 'author-list'),
path('authors/<int:pk>/details', AuthorDetailView.as_view(), name = 'author-details'),
path('books/add/', BookCreateView.as_view(), name = "add-book"),
path('books/add/', BooksCreateView.as_view(), name = "add-book"),
]
app_name = "bookshelf"
\ No newline at end of file
......@@ -26,8 +26,12 @@ class AuthorDetailView(DetailView):
model = Author
template_name = 'bookshelf/author_details.html'
class BookCreateView(CreateView):
model = Book
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'
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment