]> gitweb.fperrin.net Git - djsite.git/blob - quotes/views.py
Add a pyflakes check, and fix the warnings
[djsite.git] / quotes / views.py
1 from django.shortcuts import render
2
3 from random import randint
4
5 from .models import Author, Work, Quote, Tag
6
7 # Create your views here.
8 def onequote(request, quote_id):
9     q = Quote.objects.get(id=quote_id)
10     context = { 'quote' : q }
11     return render(request, 'quotes/onequote.html', context)
12
13 def random(request):
14     count = Quote.objects.count()
15     return onequote(request, randint(1, count))
16
17 def tags(request, tag_id):
18     tag = Tag.objects.get(id=tag_id)
19     context = { 'tag' : tag }
20     return render(request, 'quotes/tag.html', context)
21
22 def author(request, author_id):
23     author = Author.objects.get(id=author_id)
24     context = { 'author' : author }
25     return render(request, 'quotes/author.html', context)
26
27 def work(request, work_id):
28     work = Work.objects.get(id=work_id)
29     context = { 'work': work }
30     return render(request, 'quotes/work.html', context)
31
32 def all(request):
33     quotes = Quote.objects.all()
34     context = { 'quotes' : quotes }
35     return render(request, 'quotes/all.html', context)