Commit 9cf75775 authored by Joaquin Hermosisima's avatar Joaquin Hermosisima

edited views.py

parent 0a08ef79
from django.shortcuts import render
from django.views.generic.list import ListView
from django.views.generic.detail import DetailView
from .models import Author, Book
# Create your views here.
class BookListView(ListView):
model = Book
template_name = 'book_list.html'
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['title'] = "My Favorite Books"
context['nickname'] = "Jak"
context['url_list'] = ['home', 'authors']
return context
class BookDetailView(DetailView):
model = Book
template_name = "bookshelf/book_details.html"
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['nickname'] = "Jak"
context['url_list'] = ['home', 'books' ,'authors']
return context
class AuthorListView(ListView):
model = Author
template_name = 'bookshelf/author_list.html'
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['nickname'] = "Jak"
context['url_list'] = ['home', 'books']
return context
class AuthorDetailView(DetailView):
model = Author
template_name = 'bookshelf/author_details.html'
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['url_list'] = ['home', 'books', 'authors']
context['book_list'] = Book.objects.filter(author=self.object.pk)
return context
\ 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