Answers for "django render template"

0

render template in django

from django.shortcuts import render

return render(request, 'index.html')
Posted by: Guest on October-02-2021
0

django render template

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))
Posted by: Guest on October-13-2021

Python Answers by Framework

Browse Popular Code Answers by Language