Ticket #14675: docs.diff

File docs.diff, 10.2 KB (added by Pablo Fernandez, 14 years ago)

Explicitly included functions from urls.default in documentation.

  • docs/intro/overview.txt

    diff --git a/docs/intro/overview.txt b/docs/intro/overview.txt
    index 34572a6..5b02f62 100644
    a b decouple URLs from Python code.  
    176176Here's what a URLconf might look like for the ``Reporter``/``Article``
    177177example above::
    178178
    179     from django.conf.urls.defaults import *
     179    from django.conf.urls.defaults import patterns, url, include   
    180180
    181181    urlpatterns = patterns('',
    182182        (r'^articles/(\d{4})/$', 'news.views.year_archive'),
  • docs/intro/tutorial02.txt

    diff --git a/docs/intro/tutorial02.txt b/docs/intro/tutorial02.txt
    index c80d87d..d5f8728 100644
    a b activate the admin site for your installation, do these three things:  
    4343
    4444      .. parsed-literal::
    4545
    46           from django.conf.urls.defaults import *
     46          from django.conf.urls.defaults import patterns, url, include
    4747
    4848          # Uncomment the next two lines to enable the admin:
    4949          **from django.contrib import admin**
  • docs/intro/tutorial03.txt

    diff --git a/docs/intro/tutorial03.txt b/docs/intro/tutorial03.txt
    index 0843d9e..ce7e2ca 100644
    a b point at that file::  
    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, url, include
    8282
    8383    from django.contrib import admin
    8484    admin.autodiscover()
    It's just a normal view.  
    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, url, include
    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
    callback in your URLconf, you can concatenate multiple  
    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, url, include
    463463
    464464    from django.contrib import admin
    465465    admin.autodiscover()
    Copy the file ``mysite/urls.py`` to ``polls/urls.py``. Then, change  
    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, url, include
    500500   
    501501    from django.contrib import admin
    502502    admin.autodiscover()
    URLconf by removing the leading "polls/" from each line, and removing the  
    526526lines registering the admin site. Your ``polls.urls`` file should now look like
    527527this::
    528528
    529     from django.conf.urls.defaults import *
     529    from django.conf.urls.defaults import patterns, url, include
    530530
    531531    urlpatterns = patterns('polls.views',
    532532        (r'^$', 'index'),
  • docs/intro/tutorial04.txt

    diff --git a/docs/intro/tutorial04.txt b/docs/intro/tutorial04.txt
    index 606da56..f036464 100644
    a b Read on for details.  
    220220First, open the ``polls/urls.py`` URLconf. It looks like this, according to the
    221221tutorial so far::
    222222
    223     from django.conf.urls.defaults import *
     223    from django.conf.urls.defaults import patterns, url, include
    224224
    225225    urlpatterns = patterns('polls.views',
    226226        (r'^$', 'index'),
    tutorial so far::  
    231231
    232232Change it like so::
    233233
    234     from django.conf.urls.defaults import *
     234    from django.conf.urls.defaults import patterns, url, include
    235235    from django.views.generic import DetailView, ListView
    236236    from polls.models import Poll
    237237
  • docs/topics/class-based-views.txt

    diff --git a/docs/topics/class-based-views.txt b/docs/topics/class-based-views.txt
    index f0e4910..5c7f8d3 100644
    a b views themselves are classes, we point the URL to the as_view class method  
    7575instead, which is the entrypoint for class-based views::
    7676
    7777    # urls.py
    78     from django.conf.urls.defaults import *
     78    from django.conf.urls.defaults import patterns, url, include
    7979    from some_app.views import AboutView
    8080
    8181    urlpatterns = patterns('',
    Alternatively, if you're only changing a few simple attributes on a  
    8686class-based view, you can simply pass the new attributes into the as_view
    8787method call itself::
    8888
    89     from django.conf.urls.defaults import *
     89    from django.conf.urls.defaults import patterns, url, include
    9090    from django.views.generic import TemplateView
    9191
    9292    urlpatterns = patterns('',
    be using these models::  
    135135
    136136To build a list page of all publishers, we'd use a URLconf along these lines::
    137137
    138     from django.conf.urls.defaults import *
     138    from django.conf.urls.defaults import patterns, url, include
    139139    from django.views.generic import ListView
    140140    from books.models import Publisher
    141141
  • docs/topics/generic-views.txt

    diff --git a/docs/topics/generic-views.txt b/docs/topics/generic-views.txt
    index 41e32c8..e24bb84 100644
    a b URLconf tuple for a given pattern.  
    4848For example, here's a simple URLconf you could use to present a static "about"
    4949page::
    5050
    51     from django.conf.urls.defaults import *
     51    from django.conf.urls.defaults import patterns, url, include
    5252    from django.views.generic.simple import direct_to_template
    5353
    5454    urlpatterns = patterns('',
    the URLconf to point to a view function:  
    7070
    7171.. parsed-literal::
    7272
    73     from django.conf.urls.defaults import *
     73    from django.conf.urls.defaults import patterns, url, include
    7474    from django.views.generic.simple import direct_to_template
    7575    **from books.views import about_pages**
    7676
    be using these models::  
    150150
    151151To build a list page of all publishers, we'd use a URLconf along these lines::
    152152
    153     from django.conf.urls.defaults import *
     153    from django.conf.urls.defaults import patterns, url, include
    154154    from django.views.generic import list_detail
    155155    from books.models import Publisher
    156156
  • docs/topics/http/urls.txt

    diff --git a/docs/topics/http/urls.txt b/docs/topics/http/urls.txt
    index 6179c30..542ad79 100644
    a b Example  
    5959
    6060Here's a sample URLconf::
    6161
    62     from django.conf.urls.defaults import *
     62    from django.conf.urls.defaults import patterns, url, include
    6363
    6464    urlpatterns = patterns('',
    6565        (r'^articles/2003/$', 'news.views.special_case_2003'),
    Here's a sample URLconf::  
    7070
    7171Notes:
    7272
    73     * ``from django.conf.urls.defaults import *`` makes the ``patterns()``
     73    * ``from django.conf.urls.defaults import patterns, url, include`` makes the ``patterns()``
    7474      function available.
    7575
    7676    * To capture a value from the URL, just put parenthesis around it.
    Syntax of the urlpatterns variable  
    177177``django.conf.urls.defaults.patterns()``. Always use ``patterns()`` to create
    178178the ``urlpatterns`` variable.
    179179
    180 Convention is to use ``from django.conf.urls.defaults import *`` at the top of
     180Convention is to use ``from django.conf.urls.defaults import patterns, url, include`` at the top of
    181181your URLconf. This gives your module access to these objects:
    182182
    183183patterns
    code duplication.  
    335335
    336336Here's the example URLconf from the :doc:`Django overview </intro/overview>`::
    337337
    338     from django.conf.urls.defaults import *
     338    from django.conf.urls.defaults import patterns, url, include
    339339
    340340    urlpatterns = patterns('',
    341341        (r'^articles/(\d{4})/$', 'news.views.year_archive'),
    each view function.  
    350350
    351351With this in mind, the above example can be written more concisely as::
    352352
    353     from django.conf.urls.defaults import *
     353    from django.conf.urls.defaults import patterns, url, include
    354354
    355355    urlpatterns = patterns('news.views',
    356356        (r'^articles/(\d{4})/$', 'year_archive'),
    Just add multiple ``patterns()`` objects together, like this:  
    371371
    372372Old::
    373373
    374     from django.conf.urls.defaults import *
     374    from django.conf.urls.defaults import patterns, url, include
    375375
    376376    urlpatterns = patterns('',
    377377        (r'^$', 'django.views.generic.date_based.archive_index'),
    Old::  
    381381
    382382New::
    383383
    384     from django.conf.urls.defaults import *
     384    from django.conf.urls.defaults import patterns, url, include
    385385
    386386    urlpatterns = patterns('django.views.generic.date_based',
    387387        (r'^$', 'archive_index'),
    essentially "roots" a set of URLs below other ones.  
    401401For example, here's the URLconf for the `Django Web site`_ itself. It includes a
    402402number of other URLconfs::
    403403
    404     from django.conf.urls.defaults import *
     404    from django.conf.urls.defaults import patterns, url, include
    405405
    406406    urlpatterns = patterns('',
    407407        (r'^weblog/',        include('django_website.apps.blog.urls.blog')),
    Another possibility is to include additional URL patterns not by specifying the  
    421421URLconf Python module defining them as the `include`_ argument but by using
    422422directly the pattern list as returned by `patterns`_ instead. For example::
    423423
    424     from django.conf.urls.defaults import *
     424    from django.conf.urls.defaults import patterns, url, include
    425425
    426426    extra_patterns = patterns('',
    427427        url(r'reports/(?P<id>\d+)/$', 'credit.views.report', name='credit-reports'),
  • docs/topics/http/views.txt

    diff --git a/docs/topics/http/views.txt b/docs/topics/http/views.txt
    index 399e6b6..92cc8fc 100644
    a b URLconf, like so::  
    143143Behind the scenes, Django determines the 404 view by looking for ``handler404``.
    144144By default, URLconfs contain the following line::
    145145
    146     from django.conf.urls.defaults import *
     146    from django.conf.urls.defaults import patterns, url, include
    147147
    148148That takes care of setting ``handler404`` in the current module. As you can see
    149149in ``django/conf/urls/defaults.py``, ``handler404`` is set to
    URLconf, like so::  
    191191Behind the scenes, Django determines the error view by looking for ``handler500``.
    192192By default, URLconfs contain the following line::
    193193
    194     from django.conf.urls.defaults import *
     194    from django.conf.urls.defaults import patterns, url, include
    195195
    196196That takes care of setting ``handler500`` in the current module. As you can see
    197197in ``django/conf/urls/defaults.py``, ``handler500`` is set to
Back to Top