47 lines
1.1 KiB
Python
Executable File
47 lines
1.1 KiB
Python
Executable File
from django.shortcuts import render
|
|
<<<<<<< HEAD
|
|
from django.http import HttpResponse
|
|
from django.views import generic
|
|
from django.contrib.auth.decorators import login_required
|
|
=======
|
|
from django.views import generic
|
|
>>>>>>> backup
|
|
|
|
from .models import Author
|
|
from .models import Book
|
|
# Create your views here.
|
|
|
|
<<<<<<< HEAD
|
|
@login_required
|
|
def index(request):
|
|
return render(request, 'library/index.html')
|
|
=======
|
|
>>>>>>> backup
|
|
|
|
class AuthorIndexView(generic.ListView):
|
|
template_name = 'library/authorindex.html'
|
|
context_object_name = 'author_list'
|
|
|
|
def get_queryset(self):
|
|
"""Return the list of authors."""
|
|
return Author.objects.all()
|
|
|
|
|
|
class AuthorDetailView(generic.DetailView):
|
|
model = Author
|
|
template_name = 'library/authordetail.html'
|
|
|
|
|
|
class BookIndexView(generic.ListView):
|
|
template_name = 'library/bookindex.html'
|
|
context_object_name = 'book_list'
|
|
|
|
def get_queryset(self):
|
|
"""Return the list of books."""
|
|
return Book.objects.all()
|
|
|
|
|
|
class BookDetailView(generic.DetailView):
|
|
model = Book
|
|
template_name = 'library/bookdetail.html'
|