Commit 2edea7af authored by Gabriel G. Garrero's avatar Gabriel G. Garrero

Updated urls.py and views.py to account for add author function

parent e136d6e0
from django.urls import path from django.urls import path
from .views import ( from .views import (
home, BooksListView, BooksDetailView, BooksCreateView, home, BooksListView, BooksDetailView, BooksCreateView,
AuthorListView, AuthorDetailView AuthorListView, AuthorDetailView, AuthorCreateView
) )
urlpatterns = [ urlpatterns = [
...@@ -11,6 +11,7 @@ urlpatterns = [ ...@@ -11,6 +11,7 @@ urlpatterns = [
path('books/add', BooksCreateView.as_view(), name = 'add-book'), path('books/add', BooksCreateView.as_view(), name = 'add-book'),
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('authors/add', AuthorCreateView.as_view(), name = 'add-author'),
] ]
app_name = "bookshelf" app_name = "bookshelf"
\ No newline at end of file
...@@ -27,4 +27,9 @@ class AuthorListView(ListView): ...@@ -27,4 +27,9 @@ class AuthorListView(ListView):
class AuthorDetailView(DetailView): class AuthorDetailView(DetailView):
model = Author model = Author
template_name = 'bookshelf/author_details.html' template_name = 'bookshelf/author_details.html'
\ No newline at end of file
class AuthorCreateView(CreateView):
model = Author
template_name = 'bookshelf/add-author.html'
fields = '__all__'
\ 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