Commit 082d5c70 authored by Jan Enzo Salvador's avatar Jan Enzo Salvador

Added CreateView classes and UpdateView classes for books and authors

parent e2b6bb71
......@@ -3,6 +3,7 @@ from django.http import HttpResponse
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, UpdateView
from .models import Author, Books
......@@ -11,6 +12,26 @@ from .models import Author, Books
def HomepageView(request):
return render(request, 'bookshelf/home.html')
class BookCreateView(CreateView):
model = Books
fields = '__all__'
template_name = 'bookshelf/add-book.hmtl'
class AuthorCreateView(CreateView):
model = Author
fields = '__all__'
template_name = 'bookshelf/add-author.html'
class BookUpdateView(UpdateView):
model = Books
fields = '__all__'
template_name = 'bookshelf/edit-book.html'
class AuthorUpdateView(UpdateView):
model = Author
fields = '__all__'
template_name = 'bookshelf/edit-author.html'
class BooksListView(ListView):
model = Books
template_name = 'bookshelf/books.html'
......
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