X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=quotes%2Fviews.py;h=9bed533b045f73e0385f32c934e5c780d3cc2b70;hb=0b43566359216637a28247d7f9ab4121931843ed;hp=615719209327f58096622d8b3d5e8b51d3928c98;hpb=45be55604156dc0064aa32ea508df0d90ac5a17a;p=djsite.git diff --git a/quotes/views.py b/quotes/views.py index 6157192..9bed533 100644 --- a/quotes/views.py +++ b/quotes/views.py @@ -1,32 +1,35 @@ from django.shortcuts import render -from django.http import HttpResponse -from django.template import loader from random import randint -from .models import Author, Quote, Tag +from .models import Author, Work, Quote, QuoteTag # Create your views here. def onequote(request, quote_id): q = Quote.objects.get(id=quote_id) context = { 'quote' : q } - return render(request, 'quotations/onequote.html', context) + return render(request, 'quotes/onequote.html', context) def random(request): count = Quote.objects.count() return onequote(request, randint(1, count)) def tags(request, tag_id): - tag = Tag.objects.get(id=tag_id) + tag = QuoteTag.objects.get(id=tag_id) context = { 'tag' : tag } - return render(request, 'quotations/tag.html', context) + return render(request, 'quotes/tag.html', context) def author(request, author_id): author = Author.objects.get(id=author_id) context = { 'author' : author } - return render(request, 'quotations/author.html', context) + return render(request, 'quotes/author.html', context) + +def work(request, work_id): + work = Work.objects.get(id=work_id) + context = { 'work': work } + return render(request, 'quotes/work.html', context) def all(request): quotes = Quote.objects.all() context = { 'quotes' : quotes } - return render(request, 'quotations/all.html', context) + return render(request, 'quotes/all.html', context)