Changeset 2776
- Timestamp:
- 04/28/06 20:10:16 (2 years ago)
- Files:
-
- django/branches/magic-removal/docs/tutorial01.txt (modified) (1 diff)
- django/branches/magic-removal/docs/tutorial03.txt (modified) (2 diffs)
- django/branches/magic-removal/docs/tutorial04.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/magic-removal/docs/tutorial01.txt
r2725 r2776 450 450 >>> p.save() 451 451 452 # get_list() displays all the polls in the database.452 # objects.all() displays all the polls in the database. 453 453 >>> Poll.objects.all() 454 454 [<Poll object>] django/branches/magic-removal/docs/tutorial03.txt
r2707 r2776 361 361 <h1>{{ poll.question }}</h1> 362 362 <ul> 363 {% for choice in poll. get_choice_list%}363 {% for choice in poll.choice_set.all %} 364 364 <li>{{ choice.choice }}</li> 365 365 {% endfor %} … … 372 372 method ``question()`` on the poll object. 373 373 374 Method-calling happens in the ``{% for %}`` loop: ``poll. get_choice_list`` is375 interpreted as the Python code ``poll. get_choice_list()``, which returns a list376 of Choice objects and is suitable for iteration viathe ``{% for %}`` tag.374 Method-calling happens in the ``{% for %}`` loop: ``poll.choice_set.all`` is 375 interpreted as the Python code ``poll.choice_set.all()``, which returns an 376 iterable of Choice objects and is suitable for use in the ``{% for %}`` tag. 377 377 378 378 See the `template guide`_ for full details on how templates work. django/branches/magic-removal/docs/tutorial04.txt
r2774 r2776 40 40 41 41 Now, let's create a Django view that handles the submitted data and does 42 something with it. Remember, in `Tutorial 3`_, we create a URLconf for the42 something with it. Remember, in `Tutorial 3`_, we created a URLconf for the 43 43 polls application that includes this line:: 44 44 … … 152 152 You should know basic math before you start using a calculator. 153 153 154 First, open the polls .py URLconf. It looks like this, according to the tutorial155 so far::154 First, open the polls/urls.py URLconf. It looks like this, according to the 155 tutorial so far:: 156 156 157 157 from django.conf.urls.defaults import * … … 176 176 (r'^$', 'django.views.generic.list_detail.object_list', info_dict), 177 177 (r'^(?P<object_id>\d+)/$', 'django.views.generic.list_detail.object_detail', info_dict), 178 (r'^(?P<object_id>\d+)/results/$', 'django.views.generic.list_detail.object_detail', dict(info_dict, template_name='polls/results ')),178 (r'^(?P<object_id>\d+)/results/$', 'django.views.generic.list_detail.object_detail', dict(info_dict, template_name='polls/results.html')), 179 179 (r'^(?P<poll_id>\d+)/vote/$', 'mysite.polls.views.vote'), 180 180 ) … … 204 204 Because we have more than one entry in the URLconf that uses ``object_detail`` 205 205 for the polls app, we manually specify a template name for the results view: 206 ``template_name='polls/results '``. Otherwise, both views would use the same206 ``template_name='polls/results.html'``. Otherwise, both views would use the same 207 207 template. Note that we use ``dict()`` to return an altered dictionary in place. 208 208
