Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.1.X] Fixed #11959 -- Updated the tutorial to ensure that the admin…

… site continues to work after URLpatterns are introduced. Thanks to carljm for the report and draft patch.

Backport of r11621 from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@11622 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit ec9b6f2616a8794b9530558291001aa12e845125 1 parent 66939c2
Russell Keith-Magee authored October 14, 2009
1  docs/intro/tutorial01.txt
@@ -281,6 +281,7 @@ That'll create a directory :file:`polls`, which is laid out like this::
281 281
     polls/
282 282
         __init__.py
283 283
         models.py
  284
+        tests.py
284 285
         views.py
285 286
 
286 287
 This directory structure will house the poll application.
10  docs/intro/tutorial02.txt
@@ -34,11 +34,11 @@ activate the admin site for your installation, do these three things:
34 34
     * Run ``python manage.py syncdb``. Since you have added a new application
35 35
       to :setting:`INSTALLED_APPS`, the database tables need to be updated.
36 36
 
37  
-    * Edit your ``mysite/urls.py`` file and uncomment the lines below the
38  
-      "Uncomment the next two lines..." comment. This file is a URLconf;
39  
-      we'll dig into URLconfs in the next tutorial. For now, all you need to
40  
-      know is that it maps URL roots to applications. In the end, you should
41  
-      have a ``urls.py`` file that looks like this:
  37
+    * Edit your ``mysite/urls.py`` file and uncomment the lines that reference
  38
+      the admin -- there are three lines in total to uncomment. This file is a
  39
+      URLconf; we'll dig into URLconfs in the next tutorial. For now, all you
  40
+      need to know is that it maps URL roots to applications. In the end, you
  41
+      should have a ``urls.py`` file that looks like this:
42 42
 
43 43
     .. versionchanged:: 1.1
44 44
         The method for adding admin urls has changed in Django 1.1.
22  docs/intro/tutorial03.txt
@@ -171,15 +171,23 @@ and put the following Python code in it::
171 171
 This is the simplest view possible. Go to "/polls/" in your browser, and you
172 172
 should see your text.
173 173
 
174  
-Now add the following view. It's slightly different, because it takes an
175  
-argument (which, remember, is passed in from whatever was captured by the
176  
-regular expression in the URLconf)::
  174
+Now lets add a few more views. These views are slightly different, because
  175
+they take an argument (which, remember, is passed in from whatever was
  176
+captured by the regular expression in the URLconf)::
177 177
 
178 178
     def detail(request, poll_id):
179 179
         return HttpResponse("You're looking at poll %s." % poll_id)
180 180
 
181  
-Take a look in your browser, at "/polls/34/". It'll display whatever ID you
182  
-provide in the URL.
  181
+    def results(request, poll_id):
  182
+        return HttpResponse("You're looking at the results of poll %s." % poll_id)
  183
+
  184
+    def vote(request, poll_id):
  185
+        return HttpResponse("You're voting on poll %s." % poll_id)
  186
+
  187
+Take a look in your browser, at "/polls/34/". It'll run the `detail()` method
  188
+and display whatever ID you provide in the URL. Try "/polls/34/results/" and
  189
+"/polls/34/vote/" too -- these will display the placeholder results and voting
  190
+pages.
183 191
 
184 192
 Write views that actually do something
185 193
 ======================================
@@ -467,10 +475,10 @@ Copy the file ``mysite/urls.py`` to ``mysite/polls/urls.py``. Then, change
467 475
 ``mysite/urls.py`` to remove the poll-specific URLs and insert an
468 476
 :func:`~django.conf.urls.defaults.include`::
469 477
 
470  
-    ...
  478
+    # ...
471 479
     urlpatterns = patterns('',
472 480
         (r'^polls/', include('mysite.polls.urls')),
473  
-        ...
  481
+        # ...
474 482
 
475 483
 :func:`~django.conf.urls.defaults.include`, simply, references another URLconf.
476 484
 Note that the regular expression doesn't have a ``$`` (end-of-string match
5  docs/intro/tutorial04.txt
@@ -52,10 +52,11 @@ created a URLconf for the polls application that includes this line::
52 52
 
53 53
     (r'^(?P<poll_id>\d+)/vote/$', 'vote'),
54 54
 
55  
-So let's create a ``vote()`` function in ``mysite/polls/views.py``::
  55
+We also created a dummy implementation of the ``vote()`` function. Let's
  56
+create a real version. Add the following to ``mysite/polls/views.py``::
56 57
 
57 58
     from django.shortcuts import get_object_or_404, render_to_response
58  
-    from django.http import HttpResponseRedirect
  59
+    from django.http import HttpResponseRedirect, HttpResponse
59 60
     from django.core.urlresolvers import reverse
60 61
     from mysite.polls.models import Choice, Poll
61 62
     # ...

0 notes on commit ec9b6f2

Please sign in to comment.
Something went wrong with that request. Please try again.