-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathviews.py
executable file
·33 lines (28 loc) · 1.03 KB
/
views.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from catalogue.app.models import Author, Book, Movie, Person
from django.shortcuts import render_to_response, redirect, get_list_or_404, get_object_or_404
import urllib
from django.conf import settings
# from django.views.decorators.cache import cache_control
# from django.db.models import Q
def index(request):
books = Book.objects.all().order_by('title')
movies = Movie.objects.all().order_by('title')
return render_to_response('index.html', {
'books': books,
'movies': movies,
})
def book(request, title, un_id):
book = get_object_or_404(Book, title_slug=title, id=un_id)
return render_to_response('book_detail.html', {
'book': book,
})
def movie(request, title, un_id):
movie = get_object_or_404(Movie, title_slug=title, id=un_id)
return render_to_response('movie_detail.html', {
'movie': movie,
})
def currently_reading(request):
books = get_list_or_404(Book, currently_reading=True)
return render_to_response('currently_reading.html', {
'books': books,
})