Skip to content

Instantly share code, notes, and snippets.

@harijay
Last active July 8, 2018 17:26
Show Gist options
  • Save harijay/8e0817bb88a0f299c0b1cd9093fb9c7d to your computer and use it in GitHub Desktop.
Save harijay/8e0817bb88a0f299c0b1cd9093fb9c7d to your computer and use it in GitHub Desktop.
from django.http import HttpResponse
from django.template import loader
def index(request):
#Get Last five Polls
latest_questions = Question.objects.order_by('-pub_date')[:5]
template = loader.get_template("polls/index.html")
context = {
'latest_questions':latest_questions,
}
return HttpResponse(template.render(context,request))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment