Word-wrapped some code examples in tutorial03

git-svn-id: http://code.djangoproject.com/svn/django/trunk@200 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2005-07-19 05:55:42 +00:00
parent 09e825c746
commit 851b14deca
1 changed files with 4 additions and 2 deletions

View File

@ -172,7 +172,8 @@ publication date::
from django.utils.httpwrappers import HttpResponse from django.utils.httpwrappers import HttpResponse
def index(request): def index(request):
latest_poll_list = polls.get_list(order_by=[('pub_date', 'DESC')], limit=5) latest_poll_list = polls.get_list(order_by=[('pub_date', 'DESC')],
limit=5)
output = ', '.join([p.question for p in latest_poll_list]) output = ', '.join([p.question for p in latest_poll_list])
return HttpResponse(output) return HttpResponse(output)
@ -186,7 +187,8 @@ So let's use Django's template system to separate the design from Python::
from django.utils.httpwrappers import HttpResponse from django.utils.httpwrappers import HttpResponse
def index(request): def index(request):
latest_poll_list = polls.get_list(order_by=[('pub_date', 'DESC')], limit=5) latest_poll_list = polls.get_list(order_by=[('pub_date', 'DESC')],
limit=5)
t = template_loader.get_template('polls/index') t = template_loader.get_template('polls/index')
c = Context(request, { c = Context(request, {
'latest_poll_list': latest_poll_list, 'latest_poll_list': latest_poll_list,