mirror of
https://github.com/django/django.git
synced 2025-07-04 09:49:12 +00:00
magic-removal: Fixed #1704, #1682, #1693, #1694, #1695, #1696 -- Made corrections to tutorials. Thanks, Malcolm and crew
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2776 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
b4e85c7d1c
commit
07b42f2234
@ -449,7 +449,7 @@ Once you're in the shell, explore the database API::
|
||||
>>> p.pub_date = datetime(2005, 4, 1, 0, 0)
|
||||
>>> p.save()
|
||||
|
||||
# get_list() displays all the polls in the database.
|
||||
# objects.all() displays all the polls in the database.
|
||||
>>> Poll.objects.all()
|
||||
[<Poll object>]
|
||||
|
||||
|
@ -360,7 +360,7 @@ what the template might look like::
|
||||
|
||||
<h1>{{ poll.question }}</h1>
|
||||
<ul>
|
||||
{% for choice in poll.get_choice_list %}
|
||||
{% for choice in poll.choice_set.all %}
|
||||
<li>{{ choice.choice }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
@ -371,9 +371,9 @@ on the object ``poll``. Failing that, it tries attribute lookup -- which works,
|
||||
in this case. If attribute lookup had failed, it would've tried calling the
|
||||
method ``question()`` on the poll object.
|
||||
|
||||
Method-calling happens in the ``{% for %}`` loop: ``poll.get_choice_list`` is
|
||||
interpreted as the Python code ``poll.get_choice_list()``, which returns a list
|
||||
of Choice objects and is suitable for iteration via the ``{% for %}`` tag.
|
||||
Method-calling happens in the ``{% for %}`` loop: ``poll.choice_set.all`` is
|
||||
interpreted as the Python code ``poll.choice_set.all()``, which returns an
|
||||
iterable of Choice objects and is suitable for use in the ``{% for %}`` tag.
|
||||
|
||||
See the `template guide`_ for full details on how templates work.
|
||||
|
||||
|
@ -39,7 +39,7 @@ A quick rundown:
|
||||
Django; it's just good Web development practice.
|
||||
|
||||
Now, let's create a Django view that handles the submitted data and does
|
||||
something with it. Remember, in `Tutorial 3`_, we create a URLconf for the
|
||||
something with it. Remember, in `Tutorial 3`_, we created a URLconf for the
|
||||
polls application that includes this line::
|
||||
|
||||
(r'^(?P<poll_id>\d+)/vote/$', 'mysite.polls.views.vote'),
|
||||
@ -151,8 +151,8 @@ conversion.
|
||||
|
||||
You should know basic math before you start using a calculator.
|
||||
|
||||
First, open the polls.py URLconf. It looks like this, according to the tutorial
|
||||
so far::
|
||||
First, open the polls/urls.py URLconf. It looks like this, according to the
|
||||
tutorial so far::
|
||||
|
||||
from django.conf.urls.defaults import *
|
||||
|
||||
@ -175,7 +175,7 @@ Change it like so::
|
||||
urlpatterns = patterns('',
|
||||
(r'^$', 'django.views.generic.list_detail.object_list', info_dict),
|
||||
(r'^(?P<object_id>\d+)/$', 'django.views.generic.list_detail.object_detail', info_dict),
|
||||
(r'^(?P<object_id>\d+)/results/$', 'django.views.generic.list_detail.object_detail', dict(info_dict, template_name='polls/results')),
|
||||
(r'^(?P<object_id>\d+)/results/$', 'django.views.generic.list_detail.object_detail', dict(info_dict, template_name='polls/results.html')),
|
||||
(r'^(?P<poll_id>\d+)/vote/$', 'mysite.polls.views.vote'),
|
||||
)
|
||||
|
||||
@ -203,7 +203,7 @@ Similarly, the ``object_list`` generic view uses a template called
|
||||
|
||||
Because we have more than one entry in the URLconf that uses ``object_detail``
|
||||
for the polls app, we manually specify a template name for the results view:
|
||||
``template_name='polls/results'``. Otherwise, both views would use the same
|
||||
``template_name='polls/results.html'``. Otherwise, both views would use the same
|
||||
template. Note that we use ``dict()`` to return an altered dictionary in place.
|
||||
|
||||
In previous versions of the tutorial, the templates have been provided with a context
|
||||
|
Loading…
x
Reference in New Issue
Block a user