Create your views here from django template import Context Template fr

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# Create your views here.
from django.template import Context, Template
from biblequotes.models import Quote
from random import randint
from django.http import HttpResponse
def randomQuote(request):
count = Quote.objects.count()
qid = randint(1, count)
quote = Quote.objects.get(id=qid)
t = Template("<html><body>{{quote.book}}, {{quote.chapter}}:{{quote.verse}}<br /> {{quote.text}}</body></html>")
html = t.render(Context({'quote':quote}))
return HttpResponse(html)