O'Reilly logo

Django Unleashed by Andrew Pinkham

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

5.6.3 Shortening Code with render()

Before introducing the render_to_response() shortcut, our /organizer/views.py read as shown in Example 5.27.

Example 5.27: Project Code

organizer/views.py in 4d36d603db

 1  from django.http.response import HttpResponse  2  from django.shortcuts import get_object_or_404  3  from django.template import Context, loader  4  5  from .models import Tag  6  7  8  def homepage(request):  9      tag_list = Tag.objects.all() 10      template = loader.get_template( 11          'organizer/tag_list.html') 12      context = Context({'tag_list': tag_list}) 13      output = template.render(context) 14      return HttpResponse(output) 15 16 17  def tag_detail(request, slug): 18      tag = get_object_or_404( ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required