Commit c21824e5 authored by Gabriel G. Garrero's avatar Gabriel G. Garrero

Edited urls.py and views.py to account for the add book function

parent d027a198
from django.urls import path
from .views import (
home, BooksListView, BooksDetailView,
home, BooksListView, BooksDetailView, BooksCreateView,
AuthorListView, AuthorDetailView
)
......@@ -8,6 +8,7 @@ urlpatterns = [
path('home/', home, name = 'home'),
path('books/', BooksListView.as_view(), name = 'book-list'),
path('books/<int:pk>/details', BooksDetailView.as_view(), name = 'books-details'),
path('books/add', BooksCreateView.as_view(), name = 'add-book'),
path('authors/', AuthorListView.as_view(), name = 'author-list'),
path('authors/<int:pk>/details', AuthorDetailView.as_view(), name = 'author-details'),
]
......
......@@ -2,6 +2,7 @@ from django.shortcuts import render
from django.views import View
from django.views.generic.list import ListView
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView
from .models import Author, Books
def home(request):
......@@ -14,6 +15,11 @@ class BooksListView(ListView):
class BooksDetailView(DetailView):
model = Books
template_name = 'bookshelf/book_details.html'
class BooksCreateView(CreateView):
model = Books
template_name = 'bookshelf/add-book.html'
fields = '__all__'
class AuthorListView(ListView):
model = Author
......
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