mirror of
https://github.com/django/django.git
synced 2025-06-05 11:39:13 +00:00
[1.6.x] Fixed #23491 -- Clarified tutorial 3.
Thanks diek for the suggestion. Backport of 54fd84e432 from master
This commit is contained in:
parent
9a66244bd8
commit
aa1939c1d1
@ -265,7 +265,7 @@ you want, using whatever Python libraries you want.
|
|||||||
All Django wants is that :class:`~django.http.HttpResponse`. Or an exception.
|
All Django wants is that :class:`~django.http.HttpResponse`. Or an exception.
|
||||||
|
|
||||||
Because it's convenient, let's use Django's own database API, which we covered
|
Because it's convenient, let's use Django's own database API, which we covered
|
||||||
in :doc:`Tutorial 1 </intro/tutorial01>`. Here's one stab at the ``index()``
|
in :doc:`Tutorial 1 </intro/tutorial01>`. Here's one stab at a new ``index()``
|
||||||
view, which displays the latest 5 poll questions in the system, separated by
|
view, which displays the latest 5 poll questions in the system, separated by
|
||||||
commas, according to publication date::
|
commas, according to publication date::
|
||||||
|
|
||||||
@ -278,6 +278,8 @@ commas, according to publication date::
|
|||||||
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)
|
||||||
|
|
||||||
|
# Leave the rest of the views (detail, results, vote) unchanged
|
||||||
|
|
||||||
There's a problem here, though: the page's design is hard-coded in the view. If
|
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.
|
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 by
|
So let's use Django's template system to separate the design from Python by
|
||||||
|
Loading…
x
Reference in New Issue
Block a user