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 @@ ...@@ -5,13 +5,10 @@
{% block title %}Add New Book{% endblock %} {% block title %}Add New Book{% endblock %}
{% block content %} {% block content %}
<form method = "POST"> <form method = "POST">
{% csrf_token %}
{% csrf_token % }
{{ form.as_p }} {{ form.as_p }}
<input type = "submit" value = "Add Book" /> <input type = "submit" value = "Add Book" />
</form> </form>
{% endblock %} {% endblock %}
from django.urls import path from django.urls import path
from .views import ( from .views import (home, BooksListView, BooksDetailView, AuthorListView, AuthorDetailView, BooksCreateView)
home, BooksListView, BooksDetailView, AuthorListView, AuthorDetailView
)
urlpatterns = [ urlpatterns = [
path('home/', home, name = 'home'), path('home/', home, name = 'home'),
...@@ -10,7 +8,7 @@ urlpatterns = [ ...@@ -10,7 +8,7 @@ urlpatterns = [
path('authors/', AuthorListView.as_view(), name = 'author-list'), path('authors/', AuthorListView.as_view(), name = 'author-list'),
path('authors/<int:pk>/details', AuthorDetailView.as_view(), name = 'author-details'), 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" app_name = "bookshelf"
\ No newline at end of file
...@@ -26,8 +26,12 @@ class AuthorDetailView(DetailView): ...@@ -26,8 +26,12 @@ class AuthorDetailView(DetailView):
model = Author model = Author
template_name = 'bookshelf/author_details.html' template_name = 'bookshelf/author_details.html'
class BookCreateView(CreateView): class BooksCreateView(CreateView):
model = Book model = Books
fields = "__all__" fields = "__all__"
template_name = 'bookshelf/add-book.html' 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