Commit 0ec9f924 authored by Ciella's avatar Ciella

Updated views and URLs

parent 14590bb9
......@@ -6,8 +6,12 @@ urlpatterns = [
path('home/', home_view, name='home_view'),
path('books/', BooksListView.as_view(), name='books_list'),
path('books/<int:pk>/details/', BooksDetailView.as_view(), name='book_details'),
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/<int:pk>/details/', AuthorDetailView.as_view(), name='author_details'),
path('authors/add/', AuthorCreateView.as_view(), name='add-author'),
path('authors/<int:pk>/edit/', AuthorUpdateView.as_view(), name='edit-author'),
]
app_name = 'bookshelf'
\ No newline at end of file
from django.shortcuts import render
from django.views.generic.detail import DetailView
from django.views.generic.list import ListView
from django.views.generic.edit import CreateView, UpdateView
from .models import Author, Books
......@@ -18,6 +19,18 @@ class AuthorListView(ListView):
template_name = 'bookshelf/authors.html'
class AuthorCreateView(CreateView):
model = Author
fields = "__all__"
template_name = 'bookshelf/add-author.html'
class AuthorUpdateView(UpdateView):
model = Author
fields = '__all__'
template_name = 'bookshelf/edit-author.html'
class BooksDetailView(DetailView):
model = Books
template_name = 'bookshelf/book_details.html'
......@@ -25,4 +38,16 @@ class BooksDetailView(DetailView):
class BooksListView(ListView):
model = Books
template_name = 'bookshelf/books.html'
\ No newline at end of file
template_name = 'bookshelf/books.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'
\ No newline at end of file
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