Added add-book view

parent 80d9dc83
from django.urls import path
from .views import (
BooksListView, BooksDetailView, AuthorsDetailView, AuthorsListView, HomepageView, AuthorCreateView
BooksListView, BooksDetailView, AuthorsDetailView, AuthorsListView, HomepageView, AuthorCreateView, BooksCreateView
)
urlpatterns = [
......@@ -11,4 +11,5 @@ urlpatterns = [
path('authors/<int:pk>/details/', AuthorsDetailView.as_view(), name='authors-detail'),
path('home/', HomepageView, name='home'),
path('authors/add/', AuthorCreateView.as_view(), name='add-author'),
path('books/add/', BooksCreateView.as_view(), name='add-author'),
]
......@@ -6,7 +6,6 @@ from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView
from .models import Author, Books
from .forms import BooksForm, AuthorForm
def HomepageView(request):
......@@ -40,7 +39,7 @@ class AuthorCreateView(CreateView):
class BooksCreateView(CreateView):
model = Books
fields = '__all__'
template_name = 'add-books.html'
template_name = 'add-book.html'
'''
books = Books.objects.filter(author=Author)
......
<form method="post">{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Save">
</form>
\ 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