Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #16169 -- Updated tutorial to match the current project templat…

…e, specifically the urls.py. Thanks, aaugustin.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16463 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 8882c55496444d0238fa85e2e7849e79fff9e5e2 1 parent e013991
Jannis Leidel authored June 26, 2011
14  docs/intro/tutorial02.txt
@@ -40,22 +40,22 @@ activate the admin site for your installation, do these three things:
40 40
 
41 41
       .. parsed-literal::
42 42
 
43  
-          from django.conf.urls.defaults import *
  43
+          from django.conf.urls.defaults import patterns, include, url
44 44
 
45 45
           # Uncomment the next two lines to enable the admin:
46 46
           **from django.contrib import admin**
47 47
           **admin.autodiscover()**
48 48
 
49 49
           urlpatterns = patterns('',
50  
-              # Example:
51  
-              # (r'^mysite/', include('mysite.foo.urls')),
  50
+              # Examples:
  51
+              # url(r'^$', '{{ project_name }}.views.home', name='home'),
  52
+              # url(r'^{{ project_name }}/', include('{{ project_name }}.foo.urls')),
52 53
 
53  
-              # Uncomment the admin/doc line below and add 'django.contrib.admindocs'
54  
-              # to INSTALLED_APPS to enable admin documentation:
55  
-              # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
  54
+              # Uncomment the admin/doc line below to enable admin documentation:
  55
+              # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
56 56
 
57 57
               # Uncomment the next line to enable the admin:
58  
-              **(r'^admin/', include(admin.site.urls)),**
  58
+              **url(r'^admin/', include(admin.site.urls)),**
59 59
           )
60 60
 
61 61
       (The bold lines are the ones that needed to be uncommented.)
16  docs/intro/tutorial03.txt
@@ -78,7 +78,7 @@ point at that file::
78 78
 
79 79
 Time for an example. Edit ``mysite/urls.py`` so it looks like this::
80 80
 
81  
-    from django.conf.urls.defaults import *
  81
+    from django.conf.urls.defaults import patterns, include, url
82 82
 
83 83
     from django.contrib import admin
84 84
     admin.autodiscover()
@@ -88,7 +88,7 @@ Time for an example. Edit ``mysite/urls.py`` so it looks like this::
88 88
         (r'^polls/(?P<poll_id>\d+)/$', 'polls.views.detail'),
89 89
         (r'^polls/(?P<poll_id>\d+)/results/$', 'polls.views.results'),
90 90
         (r'^polls/(?P<poll_id>\d+)/vote/$', 'polls.views.vote'),
91  
-        (r'^admin/', include(admin.site.urls)),
  91
+        url(r'^admin/', include(admin.site.urls)),
92 92
     )
93 93
 
94 94
 This is worth a review. When somebody requests a page from your Web site -- say,
@@ -366,7 +366,7 @@ It's just a normal view.
366 366
 You normally won't have to bother with writing 404 views. By default, URLconfs
367 367
 have the following line up top::
368 368
 
369  
-    from django.conf.urls.defaults import *
  369
+    from django.conf.urls.defaults import patterns, include, url
370 370
 
371 371
 That takes care of setting ``handler404`` in the current module. As you can see
372 372
 in ``django/conf/urls/defaults.py``, ``handler404`` is set to
@@ -459,7 +459,7 @@ callback in your URLconf, you can concatenate multiple
459 459
 :func:`~django.conf.urls.defaults.patterns`. Your full ``mysite/urls.py`` might
460 460
 now look like this::
461 461
 
462  
-    from django.conf.urls.defaults import *
  462
+    from django.conf.urls.defaults import patterns, include, url
463 463
 
464 464
     from django.contrib import admin
465 465
     admin.autodiscover()
@@ -472,7 +472,7 @@ now look like this::
472 472
     )
473 473
     
474 474
     urlpatterns += patterns('',
475  
-        (r'^admin/', include(admin.site.urls)),
  475
+        url(r'^admin/', include(admin.site.urls)),
476 476
     )
477 477
 
478 478
 Decoupling the URLconfs
@@ -496,14 +496,14 @@ Copy the file ``mysite/urls.py`` to ``polls/urls.py``. Then, change
496 496
 :func:`~django.conf.urls.defaults.include`, leaving you with::
497 497
 
498 498
     # This also imports the include function
499  
-    from django.conf.urls.defaults import *
  499
+    from django.conf.urls.defaults import patterns, include, url
500 500
     
501 501
     from django.contrib import admin
502 502
     admin.autodiscover()
503 503
     
504 504
     urlpatterns = patterns('',
505 505
         (r'^polls/', include('polls.urls')),
506  
-        (r'^admin/', include(admin.site.urls)),
  506
+        url(r'^admin/', include(admin.site.urls)),
507 507
     )
508 508
 
509 509
 :func:`~django.conf.urls.defaults.include` simply references another URLconf.
@@ -526,7 +526,7 @@ URLconf by removing the leading "polls/" from each line, and removing the
526 526
 lines registering the admin site. Your ``polls/urls.py`` file should now look like
527 527
 this::
528 528
 
529  
-    from django.conf.urls.defaults import *
  529
+    from django.conf.urls.defaults import patterns, include, url
530 530
 
531 531
     urlpatterns = patterns('polls.views',
532 532
         (r'^$', 'index'),
4  docs/intro/tutorial04.txt
@@ -218,7 +218,7 @@ Read on for details.
218 218
 First, open the ``polls/urls.py`` URLconf. It looks like this, according to the
219 219
 tutorial so far::
220 220
 
221  
-    from django.conf.urls.defaults import *
  221
+    from django.conf.urls.defaults import patterns, include, url
222 222
 
223 223
     urlpatterns = patterns('polls.views',
224 224
         (r'^$', 'index'),
@@ -229,7 +229,7 @@ tutorial so far::
229 229
 
230 230
 Change it like so::
231 231
 
232  
-    from django.conf.urls.defaults import *
  232
+    from django.conf.urls.defaults import patterns, include, url
233 233
     from django.views.generic import DetailView, ListView
234 234
     from polls.models import Poll
235 235
 

0 notes on commit 8882c55

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