Ticket #16169: 16169.patch
File 16169.patch, 4.8 KB (added by , 13 years ago) |
---|
-
docs/intro/tutorial02.txt
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.) -
docs/intro/tutorial03.txt
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 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 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 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 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 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 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'), -
docs/intro/tutorial04.txt
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 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