Skip to content

Instantly share code, notes, and snippets.

@solidpple
Created December 17, 2017 13:51
Show Gist options
  • Save solidpple/6aa287bd6a6c14af05a2a8b8dd61ca22 to your computer and use it in GitHub Desktop.
Save solidpple/6aa287bd6a6c14af05a2a8b8dd61ca22 to your computer and use it in GitHub Desktop.
from django.http import HttpResponse
from django.template import loader
from .models import Question
def index(request):
latest_question_list = Question.objects.order_by('-pub_date')[:5]
template = loader.get_template('polls/index.html')
context = {
'latest_question_list': latest_question_list,
}
return HttpResponse(template.render(context, request))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment