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
This commit is contained in:
Jannis Leidel 2011-06-26 16:52:38 +00:00
parent e0139910f1
commit 8882c55496
3 changed files with 17 additions and 17 deletions

View File

@ -40,22 +40,22 @@ activate the admin site for your installation, do these three things:
.. parsed-literal:: .. 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: # Uncomment the next two lines to enable the admin:
**from django.contrib import admin** **from django.contrib import admin**
**admin.autodiscover()** **admin.autodiscover()**
urlpatterns = patterns('', urlpatterns = patterns('',
# Example: # Examples:
# (r'^mysite/', include('mysite.foo.urls')), # 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' # Uncomment the admin/doc line below to enable admin documentation:
# to INSTALLED_APPS to enable admin documentation: # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin: # 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.) (The bold lines are the ones that needed to be uncommented.)

View File

@ -78,7 +78,7 @@ point at that file::
Time for an example. Edit ``mysite/urls.py`` so it looks like this:: 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 from django.contrib import admin
admin.autodiscover() admin.autodiscover()
@ -88,7 +88,7 @@ Time for an example. Edit ``mysite/urls.py`` so it looks like this::
(r'^polls/(?P<poll_id>\d+)/$', 'polls.views.detail'), (r'^polls/(?P<poll_id>\d+)/$', 'polls.views.detail'),
(r'^polls/(?P<poll_id>\d+)/results/$', 'polls.views.results'), (r'^polls/(?P<poll_id>\d+)/results/$', 'polls.views.results'),
(r'^polls/(?P<poll_id>\d+)/vote/$', 'polls.views.vote'), (r'^polls/(?P<poll_id>\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, 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 You normally won't have to bother with writing 404 views. By default, URLconfs
have the following line up top:: 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 That takes care of setting ``handler404`` in the current module. As you can see
in ``django/conf/urls/defaults.py``, ``handler404`` is set to 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 :func:`~django.conf.urls.defaults.patterns`. Your full ``mysite/urls.py`` might
now look like this:: now look like this::
from django.conf.urls.defaults import * from django.conf.urls.defaults import patterns, include, url
from django.contrib import admin from django.contrib import admin
admin.autodiscover() admin.autodiscover()
@ -472,7 +472,7 @@ now look like this::
) )
urlpatterns += patterns('', urlpatterns += patterns('',
(r'^admin/', include(admin.site.urls)), url(r'^admin/', include(admin.site.urls)),
) )
Decoupling the URLconfs 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:: :func:`~django.conf.urls.defaults.include`, leaving you with::
# This also imports the include function # 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 from django.contrib import admin
admin.autodiscover() admin.autodiscover()
urlpatterns = patterns('', urlpatterns = patterns('',
(r'^polls/', include('polls.urls')), (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. :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 lines registering the admin site. Your ``polls/urls.py`` file should now look like
this:: this::
from django.conf.urls.defaults import * from django.conf.urls.defaults import patterns, include, url
urlpatterns = patterns('polls.views', urlpatterns = patterns('polls.views',
(r'^$', 'index'), (r'^$', 'index'),

View File

@ -218,7 +218,7 @@ Read on for details.
First, open the ``polls/urls.py`` URLconf. It looks like this, according to the First, open the ``polls/urls.py`` URLconf. It looks like this, according to the
tutorial so far:: tutorial so far::
from django.conf.urls.defaults import * from django.conf.urls.defaults import patterns, include, url
urlpatterns = patterns('polls.views', urlpatterns = patterns('polls.views',
(r'^$', 'index'), (r'^$', 'index'),
@ -229,7 +229,7 @@ tutorial so far::
Change it like so:: 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 django.views.generic import DetailView, ListView
from polls.models import Poll from polls.models import Poll