summaryrefslogtreecommitdiff
path: root/docs/intro/tutorial03.txt
diff options
context:
space:
mode:
authorMarten Kenbeek <marten.knbk@gmail.com>2015-05-28 17:25:52 +0200
committerTim Graham <timograham@gmail.com>2015-06-08 15:12:20 -0400
commit1e82094f1b6690018228e688303295f83e1c3d9a (patch)
treea0e209da939ebe3b64e8e38cf47a191785825da0 /docs/intro/tutorial03.txt
parent39937de7e60052d3ffa9f07fdbb9262aced35d61 (diff)
Fixed #21927 -- Made application and instance namespaces more distinct.
Made URL application namespaces be set in the included URLconf and instance namespaces in the call to include(). Deprecated other ways to set application and instance namespaces.
Diffstat (limited to 'docs/intro/tutorial03.txt')
-rw-r--r--docs/intro/tutorial03.txt16
1 files changed, 9 insertions, 7 deletions
diff --git a/docs/intro/tutorial03.txt b/docs/intro/tutorial03.txt
index 5b6c3e5ce7..9da44c3caf 100644
--- a/docs/intro/tutorial03.txt
+++ b/docs/intro/tutorial03.txt
@@ -442,18 +442,20 @@ view, and so might an app on the same project that is for a blog. How does one
make it so that Django knows which app view to create for a url when using the
``{% url %}`` template tag?
-The answer is to add namespaces to your root URLconf. In the ``mysite/urls.py``
-file, go ahead and change it to include namespacing:
+The answer is to add namespaces to your URLconf. In the ``polls/urls.py``
+file, go ahead and add an ``app_name`` to set the application namespace:
.. snippet::
- :filename: mysite/urls.py
+ :filename: polls/urls.py
- from django.conf.urls import include, url
- from django.contrib import admin
+ from django.conf.urls import url
+ app_name = 'polls'
urlpatterns = [
- url(r'^polls/', include('polls.urls', namespace="polls")),
- url(r'^admin/', include(admin.site.urls)),
+ url(r'^$', views.index, name='index'),
+ url(r'^(?P<question_id>[0-9]+)/$', views.detail, name='detail'),
+ url(r'^(?P<question_id>[0-9]+)/results/$', views.results, name='results'),
+ url(r'^(?P<question_id>[0-9]+)/vote/$', views.vote, name='vote'),
]
Now change your ``polls/index.html`` template from: