From 8882c55496444d0238fa85e2e7849e79fff9e5e2 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sun, 26 Jun 2011 16:52:38 +0000 Subject: [PATCH] Fixed #16169 -- Updated tutorial to match the current project template, specifically the urls.py. Thanks, aaugustin. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16463 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/intro/tutorial02.txt | 14 +++++++------- docs/intro/tutorial03.txt | 16 ++++++++-------- docs/intro/tutorial04.txt | 4 ++-- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/docs/intro/tutorial02.txt b/docs/intro/tutorial02.txt index bae47c8696..7d2ce4fc1d 100644 --- a/docs/intro/tutorial02.txt +++ b/docs/intro/tutorial02.txt @@ -40,22 +40,22 @@ activate the admin site for your installation, do these three things: .. parsed-literal:: - from django.conf.urls.defaults import * + from django.conf.urls.defaults import patterns, include, url # Uncomment the next two lines to enable the admin: **from django.contrib import admin** **admin.autodiscover()** urlpatterns = patterns('', - # Example: - # (r'^mysite/', include('mysite.foo.urls')), + # Examples: + # url(r'^$', '{{ project_name }}.views.home', name='home'), + # url(r'^{{ project_name }}/', include('{{ project_name }}.foo.urls')), - # Uncomment the admin/doc line below and add 'django.contrib.admindocs' - # to INSTALLED_APPS to enable admin documentation: - # (r'^admin/doc/', include('django.contrib.admindocs.urls')), + # Uncomment the admin/doc line below to enable admin documentation: + # url(r'^admin/doc/', include('django.contrib.admindocs.urls')), # Uncomment the next line to enable the admin: - **(r'^admin/', include(admin.site.urls)),** + **url(r'^admin/', include(admin.site.urls)),** ) (The bold lines are the ones that needed to be uncommented.) diff --git a/docs/intro/tutorial03.txt b/docs/intro/tutorial03.txt index 41a62a72d7..6cae8de763 100644 --- a/docs/intro/tutorial03.txt +++ b/docs/intro/tutorial03.txt @@ -78,7 +78,7 @@ point at that file:: Time for an example. Edit ``mysite/urls.py`` so it looks like this:: - from django.conf.urls.defaults import * + from django.conf.urls.defaults import patterns, include, url from django.contrib import admin admin.autodiscover() @@ -88,7 +88,7 @@ Time for an example. Edit ``mysite/urls.py`` so it looks like this:: (r'^polls/(?P\d+)/$', 'polls.views.detail'), (r'^polls/(?P\d+)/results/$', 'polls.views.results'), (r'^polls/(?P\d+)/vote/$', 'polls.views.vote'), - (r'^admin/', include(admin.site.urls)), + url(r'^admin/', include(admin.site.urls)), ) 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. You normally won't have to bother with writing 404 views. By default, URLconfs have the following line up top:: - from django.conf.urls.defaults import * + from django.conf.urls.defaults import patterns, include, url That takes care of setting ``handler404`` in the current module. As you can see in ``django/conf/urls/defaults.py``, ``handler404`` is set to @@ -459,7 +459,7 @@ callback in your URLconf, you can concatenate multiple :func:`~django.conf.urls.defaults.patterns`. Your full ``mysite/urls.py`` might now look like this:: - from django.conf.urls.defaults import * + from django.conf.urls.defaults import patterns, include, url from django.contrib import admin admin.autodiscover() @@ -472,7 +472,7 @@ now look like this:: ) urlpatterns += patterns('', - (r'^admin/', include(admin.site.urls)), + url(r'^admin/', include(admin.site.urls)), ) Decoupling the URLconfs @@ -496,14 +496,14 @@ Copy the file ``mysite/urls.py`` to ``polls/urls.py``. Then, change :func:`~django.conf.urls.defaults.include`, leaving you with:: # This also imports the include function - from django.conf.urls.defaults import * + from django.conf.urls.defaults import patterns, include, url from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', (r'^polls/', include('polls.urls')), - (r'^admin/', include(admin.site.urls)), + url(r'^admin/', include(admin.site.urls)), ) :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 lines registering the admin site. Your ``polls/urls.py`` file should now look like this:: - from django.conf.urls.defaults import * + from django.conf.urls.defaults import patterns, include, url urlpatterns = patterns('polls.views', (r'^$', 'index'), diff --git a/docs/intro/tutorial04.txt b/docs/intro/tutorial04.txt index ded5cb2199..86d4eef9b7 100644 --- a/docs/intro/tutorial04.txt +++ b/docs/intro/tutorial04.txt @@ -218,7 +218,7 @@ Read on for details. First, open the ``polls/urls.py`` URLconf. It looks like this, according to the tutorial so far:: - from django.conf.urls.defaults import * + from django.conf.urls.defaults import patterns, include, url urlpatterns = patterns('polls.views', (r'^$', 'index'), @@ -229,7 +229,7 @@ tutorial so far:: Change it like so:: - from django.conf.urls.defaults import * + from django.conf.urls.defaults import patterns, include, url from django.views.generic import DetailView, ListView from polls.models import Poll