Boston Python Workshop/Saturday/Web app project: Difference between revisions

Line 541:
All Django wants is that HttpResponse. Or an exception.
 
Most of the Django views in the world use Django's own database API, which we covered in Tutorial 1. Let's do that, too. Here's one stab at the index() view, which displays the latest 5 poll questions in the system, separated by commas, according to publication date. Continue editing the file views.py:
 
from polls.models import Poll
Line 551:
return HttpResponse(output)
 
There's a problem here, though: The page's design is hard-coded in the view. If you want to change the way the page looks, you'll have to edit this Python code. So let's use Django's template system to separate the design from Python. Continue editing views.py:
 
from django.shortcuts import render_to_response
Anonymous user