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

Updated urls.py and views.py to account for edit book function

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