Skip to content

Instantly share code, notes, and snippets.

@harijay
Created July 8, 2018 17:41
Show Gist options
  • Save harijay/5ac5a78f0e21635c4221f9c63f26bd28 to your computer and use it in GitHub Desktop.
Save harijay/5ac5a78f0e21635c4221f9c63f26bd28 to your computer and use it in GitHub Desktop.
from django.shortcuts import render
def index(request):
#Get Last five Polls and now use the render shortcut , I like this option less
latest_questions = Question.objects.order_by('-pub_date')[:5]
context = {
'latest_questions':latest_questions,
}
return render(request,"polls/index.html",context)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment