summaryrefslogtreecommitdiff
path: root/docs/intro/tutorial03.txt
diff options
context:
space:
mode:
Diffstat (limited to 'docs/intro/tutorial03.txt')
-rw-r--r--docs/intro/tutorial03.txt30
1 files changed, 15 insertions, 15 deletions
diff --git a/docs/intro/tutorial03.txt b/docs/intro/tutorial03.txt
index 82cf60b118..a489a77930 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 patterns, include, url
+ from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
@@ -367,7 +367,7 @@ special: 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 patterns, include, url
+ from django.conf.urls 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
@@ -443,7 +443,7 @@ Namely, ``polls.views`` is in every callback.
Because this is a common case, the URLconf framework provides a shortcut for
common prefixes. You can factor out the common prefixes and add them as the
-first argument to :func:`~django.conf.urls.defaults.patterns`, like so::
+first argument to :func:`~django.conf.urls.patterns`, like so::
urlpatterns = patterns('polls.views',
(r'^polls/$', 'index'),
@@ -457,21 +457,21 @@ tidier.
Since you generally don't want the prefix for one app to be applied to every
callback in your URLconf, you can concatenate multiple
-:func:`~django.conf.urls.defaults.patterns`. Your full ``mysite/urls.py`` might
+:func:`~django.conf.urls.patterns`. Your full ``mysite/urls.py`` might
now look like this::
- from django.conf.urls.defaults import patterns, include, url
+ from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
-
+
urlpatterns = patterns('polls.views',
(r'^polls/$', 'index'),
(r'^polls/(?P<poll_id>\d+)/$', 'detail'),
(r'^polls/(?P<poll_id>\d+)/results/$', 'results'),
(r'^polls/(?P<poll_id>\d+)/vote/$', 'vote'),
)
-
+
urlpatterns += patterns('',
url(r'^admin/', include(admin.site.urls)),
)
@@ -494,23 +494,23 @@ URLs within the app directory.
Copy the file ``mysite/urls.py`` to ``polls/urls.py``. Then, change
``mysite/urls.py`` to remove the poll-specific URLs and insert an
-:func:`~django.conf.urls.defaults.include`, leaving you with::
+:func:`~django.conf.urls.include`, leaving you with::
# This also imports the include function
- from django.conf.urls.defaults import patterns, include, url
-
+ from django.conf.urls import patterns, include, url
+
from django.contrib import admin
admin.autodiscover()
-
+
urlpatterns = patterns('',
(r'^polls/', include('polls.urls')),
url(r'^admin/', include(admin.site.urls)),
)
-:func:`~django.conf.urls.defaults.include` simply references another URLconf.
+:func:`~django.conf.urls.include` simply references another URLconf.
Note that the regular expression doesn't have a ``$`` (end-of-string match
character) but has the trailing slash. Whenever Django encounters
-:func:`~django.conf.urls.defaults.include`, it chops off whatever part of the
+:func:`~django.conf.urls.include`, it chops off whatever part of the
URL matched up to that point and sends the remaining string to the included
URLconf for further processing.
@@ -527,7 +527,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 patterns, include, url
+ from django.conf.urls import patterns, include, url
urlpatterns = patterns('polls.views',
(r'^$', 'index'),
@@ -536,7 +536,7 @@ this::
(r'^(?P<poll_id>\d+)/vote/$', 'vote'),
)
-The idea behind :func:`~django.conf.urls.defaults.include` and URLconf
+The idea behind :func:`~django.conf.urls.include` and URLconf
decoupling is to make it easy to plug-and-play URLs. Now that polls are in their
own URLconf, they can be placed under "/polls/", or under "/fun_polls/", or
under "/content/polls/", or any other path root, and the app will still work.