from django.http.response import HttpResponse

from .models import Tag


def homepage(request):
    tag_list = Tag.objects.all()
    html_output = "<html>\n"
    html_output += "<head>\n"
    html_output += "  <title>"
    html_output += "Don't Do This!</title>\n"
    html_output += "</head>\n"
    html_output += "<body>\n"
    html_output += "  <ul>\n"
    for tag in tag_list:
        html_output += "    <li>"
        html_output += tag.name.title()
        html_output += "</li>\n"
    html_output += "  </ul>\n"
    html_output += "</body>\n"
    html_output += "</html>\n"
    return HttpResponse(html_output)

from django.http.response import HttpResponse
from django.template import Context, loader

from .models import Tag


def homepage(request):
    tag_list = Tag.objects.all()
    template = loader.get_template(
        'organizer/tag_list.html')
    context = Context({'tag_list': tag_list})
    output = template.render(context)
    return HttpResponse(output)

Use template in homepage view.
Ch04: Use template in homepage view.
