mirror of https://github.com/django/django.git
Fixed #10553 -- Corrected several uses of `URLconf` in documentation and comments, according to the Django style guide. Based on patch from rduffield.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10256 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
3a0950739b
commit
b4f5655c86
|
@ -15,7 +15,7 @@ def autodiscover():
|
||||||
may want.
|
may want.
|
||||||
"""
|
"""
|
||||||
# Bail out if autodiscover didn't finish loading from a previous call so
|
# Bail out if autodiscover didn't finish loading from a previous call so
|
||||||
# that we avoid running autodiscover again when the URLConf is loaded by
|
# that we avoid running autodiscover again when the URLconf is loaded by
|
||||||
# the exception handler to resolve the handler500 view. This prevents an
|
# the exception handler to resolve the handler500 view. This prevents an
|
||||||
# admin.py module with errors from re-registering models and raising a
|
# admin.py module with errors from re-registering models and raising a
|
||||||
# spurious AlreadyRegistered exception (see #8245).
|
# spurious AlreadyRegistered exception (see #8245).
|
||||||
|
|
|
@ -24,7 +24,7 @@ class NotRegistered(Exception):
|
||||||
class AdminSite(object):
|
class AdminSite(object):
|
||||||
"""
|
"""
|
||||||
An AdminSite object encapsulates an instance of the Django admin application, ready
|
An AdminSite object encapsulates an instance of the Django admin application, ready
|
||||||
to be hooked in to your URLConf. Models are registered with the AdminSite using the
|
to be hooked in to your URLconf. Models are registered with the AdminSite using the
|
||||||
register() method, and the root() method can then be used as a Django view function
|
register() method, and the root() method can then be used as a Django view function
|
||||||
that presents a full admin interface for the collection of registered models.
|
that presents a full admin interface for the collection of registered models.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -47,8 +47,8 @@ class PasswordResetTest(TestCase):
|
||||||
|
|
||||||
def test_confirm_invalid(self):
|
def test_confirm_invalid(self):
|
||||||
url, path = self._test_confirm_start()
|
url, path = self._test_confirm_start()
|
||||||
# Lets munge the token in the path, but keep the same length,
|
# Let's munge the token in the path, but keep the same length,
|
||||||
# in case the URL conf will reject a different length
|
# in case the URLconf will reject a different length.
|
||||||
path = path[:-5] + ("0"*4) + path[-1]
|
path = path[:-5] + ("0"*4) + path[-1]
|
||||||
|
|
||||||
response = self.client.get(path)
|
response = self.client.get(path)
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
"""
|
"""
|
||||||
|
This is a URLconf to be loaded by tests.py. Add any URLs needed for tests only.
|
||||||
|
"""
|
||||||
|
|
||||||
This is a urlconf to be loaded by tests.py. Add any urls needed
|
|
||||||
for tests only.
|
|
||||||
|
|
||||||
"""
|
|
||||||
from django.conf.urls.defaults import *
|
from django.conf.urls.defaults import *
|
||||||
from django.contrib.formtools.tests import *
|
from django.contrib.formtools.tests import *
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ except NameError:
|
||||||
from django.utils.itercompat import reversed # Python 2.3 fallback
|
from django.utils.itercompat import reversed # Python 2.3 fallback
|
||||||
from sets import Set as set
|
from sets import Set as set
|
||||||
|
|
||||||
_resolver_cache = {} # Maps urlconf modules to RegexURLResolver instances.
|
_resolver_cache = {} # Maps URLconf modules to RegexURLResolver instances.
|
||||||
_callable_cache = {} # Maps view and url pattern names to their view functions.
|
_callable_cache = {} # Maps view and url pattern names to their view functions.
|
||||||
|
|
||||||
# SCRIPT_NAME prefixes for each thread are stored here. If there's no entry for
|
# SCRIPT_NAME prefixes for each thread are stored here. If there's no entry for
|
||||||
|
@ -141,7 +141,7 @@ class RegexURLPattern(object):
|
||||||
class RegexURLResolver(object):
|
class RegexURLResolver(object):
|
||||||
def __init__(self, regex, urlconf_name, default_kwargs=None):
|
def __init__(self, regex, urlconf_name, default_kwargs=None):
|
||||||
# regex is a string representing a regular expression.
|
# regex is a string representing a regular expression.
|
||||||
# urlconf_name is a string representing the module containing urlconfs.
|
# urlconf_name is a string representing the module containing URLconfs.
|
||||||
self.regex = re.compile(regex, re.UNICODE)
|
self.regex = re.compile(regex, re.UNICODE)
|
||||||
self.urlconf_name = urlconf_name
|
self.urlconf_name = urlconf_name
|
||||||
if not isinstance(urlconf_name, basestring):
|
if not isinstance(urlconf_name, basestring):
|
||||||
|
|
|
@ -58,12 +58,12 @@ be passed through to the mod_python handler in Django, via the ``PythonOption
|
||||||
django.root ...`` line. The value set on that line (the last item) should
|
django.root ...`` line. The value set on that line (the last item) should
|
||||||
match the string given in the ``<Location ...>`` directive. The effect of this
|
match the string given in the ``<Location ...>`` directive. The effect of this
|
||||||
is that Django will automatically strip the ``/mysite`` string from the front
|
is that Django will automatically strip the ``/mysite`` string from the front
|
||||||
of any URLs before matching them against your ``URLConf`` patterns. If you
|
of any URLs before matching them against your URLconf patterns. If you later
|
||||||
later move your site to live under ``/mysite2``, you will not have to change
|
move your site to live under ``/mysite2``, you will not have to change anything
|
||||||
anything except the ``django.root`` option in the config file.
|
except the ``django.root`` option in the config file.
|
||||||
|
|
||||||
When using ``django.root`` you should make sure that what's left, after the
|
When using ``django.root`` you should make sure that what's left, after the
|
||||||
prefix has been removed, begins with a slash. Your URLConf patterns that are
|
prefix has been removed, begins with a slash. Your URLconf patterns that are
|
||||||
expecting an initial slash will then work correctly. In the above example,
|
expecting an initial slash will then work correctly. In the above example,
|
||||||
since we want to send things like ``/mysite/admin/`` to ``/admin/``, we need
|
since we want to send things like ``/mysite/admin/`` to ``/admin/``, we need
|
||||||
to remove the string ``/mysite`` from the beginning, so that is the
|
to remove the string ``/mysite`` from the beginning, so that is the
|
||||||
|
|
|
@ -290,7 +290,7 @@ The ``permalink`` decorator
|
||||||
|
|
||||||
The problem with the way we wrote ``get_absolute_url()`` above is that it
|
The problem with the way we wrote ``get_absolute_url()`` above is that it
|
||||||
slightly violates the DRY principle: the URL for this object is defined both
|
slightly violates the DRY principle: the URL for this object is defined both
|
||||||
in the URLConf file and in the model.
|
in the URLconf file and in the model.
|
||||||
|
|
||||||
You can further decouple your models from the URLconf using the ``permalink``
|
You can further decouple your models from the URLconf using the ``permalink``
|
||||||
decorator:
|
decorator:
|
||||||
|
|
|
@ -82,7 +82,7 @@ Other new features and changes introduced since Django 1.0 include:
|
||||||
(sending admin requests to the ``admin.site.root`` view still works, but URLs
|
(sending admin requests to the ``admin.site.root`` view still works, but URLs
|
||||||
in the admin will not be "reversible" when configured this way).
|
in the admin will not be "reversible" when configured this way).
|
||||||
|
|
||||||
* The ``include()`` function in Django URLConf modules can now accept sequences
|
* The ``include()`` function in Django URLconf modules can now accept sequences
|
||||||
of URL patterns (generated by ``patterns()``) in addition to module names.
|
of URL patterns (generated by ``patterns()``) in addition to module names.
|
||||||
|
|
||||||
* Instances of Django forms (see `the forms overview <topics-forms-index>`_ now
|
* Instances of Django forms (see `the forms overview <topics-forms-index>`_ now
|
||||||
|
|
|
@ -623,13 +623,13 @@ reverse such patterns.
|
||||||
.. admonition:: Make sure your views are all correct
|
.. admonition:: Make sure your views are all correct
|
||||||
|
|
||||||
As part of working out which URL names map to which patterns, the
|
As part of working out which URL names map to which patterns, the
|
||||||
``reverse()`` function has to import all of your URLConf files and examine
|
``reverse()`` function has to import all of your URLconf files and examine
|
||||||
the name of each view. This involves importing each view function. If
|
the name of each view. This involves importing each view function. If
|
||||||
there are *any* errors whilst importing any of your view functions, it
|
there are *any* errors whilst importing any of your view functions, it
|
||||||
will cause ``reverse()`` to raise an error, even if that view function is
|
will cause ``reverse()`` to raise an error, even if that view function is
|
||||||
not the one you are trying to reverse.
|
not the one you are trying to reverse.
|
||||||
|
|
||||||
Make sure that any views you reference in your URLConf files exist and can
|
Make sure that any views you reference in your URLconf files exist and can
|
||||||
be imported correctly. Do not include lines that reference views you
|
be imported correctly. Do not include lines that reference views you
|
||||||
haven't written yet, because those views will not be importable.
|
haven't written yet, because those views will not be importable.
|
||||||
|
|
||||||
|
|
|
@ -444,7 +444,7 @@ class UrlconfSubstitutionTests(TestCase):
|
||||||
urls = 'regressiontests.test_client_regress.urls'
|
urls = 'regressiontests.test_client_regress.urls'
|
||||||
|
|
||||||
def test_urlconf_was_changed(self):
|
def test_urlconf_was_changed(self):
|
||||||
"TestCase can enforce a custom URLConf on a per-test basis"
|
"TestCase can enforce a custom URLconf on a per-test basis"
|
||||||
url = reverse('arg_view', args=['somename'])
|
url = reverse('arg_view', args=['somename'])
|
||||||
self.assertEquals(url, '/arg_view/somename/')
|
self.assertEquals(url, '/arg_view/somename/')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue