CBV implmentation, created method called BookCreateView

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