CBV implmentation, created method called BookCreateView

parent a4f1e0aa
from django.http import HttpResponse from django.http import HttpResponse
from django.shortcuts import render from django.shortcuts import render
from django.views import View from django.views import View
from .models import Author, Book
from django.views.generic.detail import DetailView from django.views.generic.detail import DetailView
from django.views.generic.list import ListView from django.views.generic.list import ListView
from .models import Author, Book from django.views.generic.edit import CreateView, UpdateView
def HomeView(request): def HomeView(request):
return render(request, "bookshelf/home.html") return render(request, "bookshelf/home.html")
...@@ -16,6 +18,11 @@ class BookDetailView(DetailView): ...@@ -16,6 +18,11 @@ class BookDetailView(DetailView):
model = Book model = Book
template_name = 'bookshelf/book_details.html' template_name = 'bookshelf/book_details.html'
class BookCreateView(CreateView):
model = Book
template_name = 'bookshelf/add-book.html'
fields = '__all__'
class AuthorListView(ListView): class AuthorListView(ListView):
model = Author model = Author
template_name = 'bookshelf/authors.html' template_name = 'bookshelf/authors.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