Code

Ticket #16169: 16169.patch

File 16169.patch, 4.8 KB (added by aaugustin, 3 years ago)
  • docs/intro/tutorial02.txt

     
    4040 
    4141      .. parsed-literal:: 
    4242 
    43           from django.conf.urls.defaults import * 
     43          from django.conf.urls.defaults import patterns, include, url 
    4444 
    4545          # Uncomment the next two lines to enable the admin: 
    4646          **from django.contrib import admin** 
    4747          **admin.autodiscover()** 
    4848 
    4949          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')), 
    5253 
    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')), 
    5656 
    5757              # Uncomment the next line to enable the admin: 
    58               **(r'^admin/', include(admin.site.urls)),** 
     58              **url(r'^admin/', include(admin.site.urls)),** 
    5959          ) 
    6060 
    6161      (The bold lines are the ones that needed to be uncommented.) 
  • docs/intro/tutorial03.txt

     
    7878 
    7979Time for an example. Edit ``mysite/urls.py`` so it looks like this:: 
    8080 
    81     from django.conf.urls.defaults import * 
     81    from django.conf.urls.defaults import patterns, include, url 
    8282 
    8383    from django.contrib import admin 
    8484    admin.autodiscover() 
     
    8888        (r'^polls/(?P<poll_id>\d+)/$', 'polls.views.detail'), 
    8989        (r'^polls/(?P<poll_id>\d+)/results/$', 'polls.views.results'), 
    9090        (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)), 
    9292    ) 
    9393 
    9494This is worth a review. When somebody requests a page from your Web site -- say, 
     
    366366You normally won't have to bother with writing 404 views. By default, URLconfs 
    367367have the following line up top:: 
    368368 
    369     from django.conf.urls.defaults import * 
     369    from django.conf.urls.defaults import patterns, include, url 
    370370 
    371371That takes care of setting ``handler404`` in the current module. As you can see 
    372372in ``django/conf/urls/defaults.py``, ``handler404`` is set to 
     
    459459:func:`~django.conf.urls.defaults.patterns`. Your full ``mysite/urls.py`` might 
    460460now look like this:: 
    461461 
    462     from django.conf.urls.defaults import * 
     462    from django.conf.urls.defaults import patterns, include, url 
    463463 
    464464    from django.contrib import admin 
    465465    admin.autodiscover() 
     
    472472    ) 
    473473     
    474474    urlpatterns += patterns('', 
    475         (r'^admin/', include(admin.site.urls)), 
     475        url(r'^admin/', include(admin.site.urls)), 
    476476    ) 
    477477 
    478478Decoupling the URLconfs 
     
    496496:func:`~django.conf.urls.defaults.include`, leaving you with:: 
    497497 
    498498    # This also imports the include function 
    499     from django.conf.urls.defaults import * 
     499    from django.conf.urls.defaults import patterns, include, url 
    500500     
    501501    from django.contrib import admin 
    502502    admin.autodiscover() 
    503503     
    504504    urlpatterns = patterns('', 
    505505        (r'^polls/', include('polls.urls')), 
    506         (r'^admin/', include(admin.site.urls)), 
     506        url(r'^admin/', include(admin.site.urls)), 
    507507    ) 
    508508 
    509509:func:`~django.conf.urls.defaults.include` simply references another URLconf. 
     
    526526lines registering the admin site. Your ``polls/urls.py`` file should now look like 
    527527this:: 
    528528 
    529     from django.conf.urls.defaults import * 
     529    from django.conf.urls.defaults import patterns, include, url 
    530530 
    531531    urlpatterns = patterns('polls.views', 
    532532        (r'^$', 'index'), 
  • docs/intro/tutorial04.txt

     
    218218First, open the ``polls/urls.py`` URLconf. It looks like this, according to the 
    219219tutorial so far:: 
    220220 
    221     from django.conf.urls.defaults import * 
     221    from django.conf.urls.defaults import patterns, include, url 
    222222 
    223223    urlpatterns = patterns('polls.views', 
    224224        (r'^$', 'index'), 
     
    229229 
    230230Change it like so:: 
    231231 
    232     from django.conf.urls.defaults import * 
     232    from django.conf.urls.defaults import patterns, include, url 
    233233    from django.views.generic import DetailView, ListView 
    234234    from polls.models import Poll 
    235235