Commit 0ce15583 authored by Agu Syquia's avatar Agu Syquia

Updated views.py

Added CreateView and UpdateView classes.
parent a448f4d5
......@@ -4,14 +4,35 @@ from django.views import View
from django.views.generic.list import ListView
from django.views.generic.detail import DetailView
from .models import Books, Author
from django.views.generic.edit import CreateView, UpdateView
def home_view(request):
return render(request, 'bookshelf/home.html')
class BooksCreateView(CreateView):
model = Books
fields = '__all__'
template_name = 'bookshelf/add-book.html'
class BooksUpdateView(UpdateView):
model = Books
fields = '__all__'
template_name = 'bookshelf/edit-book.html'
class AuthorsCreateView(CreateView):
model = Author
fields = '__all__'
template_name = 'bookshelf/add-author.html'
class AuthorsUpdateView(UpdateView):
model = Author
fields = '__all__'
template_name = 'bookshelf/edit-author.html'
class BooksView(ListView):
model = Books
template_name = 'bookshelf/books.html'
class BooksDetailsView(DetailView):
model = Books
template_name = 'bookshelf/book_details.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