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
# 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)
+
+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)
+ context = { 'tag' : tag }
+ return render(request, 'quotations/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)
+
+def all(request):
+ quotes = Quote.objects.all()
+ context = { 'quotes' : quotes }
+ return render(request, 'quotations/all.html', context)