Loading django/conf/urls/__init__.py +1 −18 Original line number Diff line number Diff line Loading @@ -10,7 +10,7 @@ from django.utils.deprecation import ( RemovedInDjango20Warning, RemovedInDjango110Warning, ) __all__ = ['handler400', 'handler403', 'handler404', 'handler500', 'include', 'patterns', 'url'] __all__ = ['handler400', 'handler403', 'handler404', 'handler500', 'include', 'url'] handler400 = 'django.views.defaults.bad_request' handler403 = 'django.views.defaults.permission_denied' Loading Loading @@ -76,23 +76,6 @@ def include(arg, namespace=None, app_name=None): return (urlconf_module, app_name, namespace) def patterns(prefix, *args): warnings.warn( 'django.conf.urls.patterns() is deprecated and will be removed in ' 'Django 1.10. Update your urlpatterns to be a list of ' 'django.conf.urls.url() instances instead.', RemovedInDjango110Warning, stacklevel=2 ) pattern_list = [] for t in args: if isinstance(t, (list, tuple)): t = url(prefix=prefix, *t) elif isinstance(t, RegexURLPattern): t.add_prefix(prefix) pattern_list.append(t) return pattern_list def url(regex, view, kwargs=None, name=None, prefix=''): if isinstance(view, (list, tuple)): # For include(...) processing. Loading django/conf/urls/i18n.py +4 −19 Original line number Diff line number Diff line import warnings from django.conf import settings from django.conf.urls import patterns, url from django.conf.urls import url from django.core.urlresolvers import LocaleRegexURLResolver from django.utils import six from django.utils.deprecation import RemovedInDjango110Warning from django.views.i18n import set_language def i18n_patterns(prefix, *args): def i18n_patterns(*urls): """ Adds the language code prefix to every URL pattern within this function. This may only be used in the root URLconf, not in an included URLconf. """ if isinstance(prefix, six.string_types): warnings.warn( "Calling i18n_patterns() with the `prefix` argument and with tuples " "instead of django.conf.urls.url() instances is deprecated and " "will no longer work in Django 1.10. Use a list of " "django.conf.urls.url() instances instead.", RemovedInDjango110Warning, stacklevel=2 ) pattern_list = patterns(prefix, *args) else: pattern_list = [prefix] + list(args) if not settings.USE_I18N: return pattern_list return [LocaleRegexURLResolver(pattern_list)] return urls return [LocaleRegexURLResolver(list(urls))] urlpatterns = [ Loading django/core/urlresolvers.py +0 −8 Original line number Diff line number Diff line Loading @@ -223,14 +223,6 @@ class RegexURLPattern(LocaleRegexProvider): def __repr__(self): return force_str('<%s %s %s>' % (self.__class__.__name__, self.name, self.regex.pattern)) def add_prefix(self, prefix): """ Adds the prefix string to a string-based callback. """ if not prefix or not hasattr(self, '_callback_str'): return self._callback_str = prefix + '.' + self._callback_str def resolve(self, path): match = self.regex.search(path) if match: Loading docs/internals/deprecation.txt +1 −1 Original line number Diff line number Diff line Loading @@ -626,7 +626,7 @@ details on these changes. :mod:`django.contrib.gis.utils` will be removed. * ``django.conf.urls.defaults`` will be removed. The functions :func:`~django.conf.urls.include`, :func:`~django.conf.urls.patterns` and :func:`~django.conf.urls.include`, ``patterns()`` and :func:`~django.conf.urls.url` plus :data:`~django.conf.urls.handler404`, :data:`~django.conf.urls.handler500`, are now available through :mod:`django.conf.urls` . Loading docs/ref/urls.txt +0 −71 Original line number Diff line number Diff line Loading @@ -4,77 +4,6 @@ .. module:: django.conf.urls patterns() ---------- .. function:: patterns(prefix, pattern_description, ...) .. deprecated:: 1.8 ``urlpatterns`` should be a plain list of :func:`django.conf.urls.url` instances instead. A function that takes a prefix, and an arbitrary number of URL patterns, and returns a list of URL patterns in the format Django needs. The first argument to ``patterns()`` is a string ``prefix``. Here's the example URLconf from the :doc:`Django overview </intro/overview>`:: from django.conf.urls import patterns, url urlpatterns = patterns('', url(r'^articles/([0-9]{4})/$', 'news.views.year_archive'), url(r'^articles/([0-9]{4})/([0-9]{2})/$', 'news.views.month_archive'), url(r'^articles/([0-9]{4})/([0-9]{2})/([0-9]+)/$', 'news.views.article_detail'), ) In this example, each view has a common prefix -- ``'news.views'``. Instead of typing that out for each entry in ``urlpatterns``, you can use the first argument to the ``patterns()`` function to specify a prefix to apply to each view function. With this in mind, the above example can be written more concisely as:: from django.conf.urls import patterns, url urlpatterns = patterns('news.views', url(r'^articles/([0-9]{4})/$', 'year_archive'), url(r'^articles/([0-9]{4})/([0-9]{2})/$', 'month_archive'), url(r'^articles/([0-9]{4})/([0-9]{2})/([0-9]+)/$', 'article_detail'), ) Note that you don't put a trailing dot (``"."``) in the prefix. Django puts that in automatically. The remaining arguments should be tuples in this format:: (regular expression, Python callback function [, optional_dictionary [, optional_name]]) The ``optional_dictionary`` and ``optional_name`` parameters are described in :ref:`Passing extra options to view functions <views-extra-options>`. .. note:: Because ``patterns()`` is a function call, it accepts a maximum of 255 arguments (URL patterns, in this case). This is a limit for all Python function calls. This is rarely a problem in practice, because you'll typically structure your URL patterns modularly by using ``include()`` sections. However, on the off-chance you do hit the 255-argument limit, realize that ``patterns()`` returns a Python list, so you can split up the construction of the list. :: urlpatterns = patterns('', ... ) urlpatterns += patterns('', ... ) Python lists have unlimited size, so there's no limit to how many URL patterns you can construct. The only limit is that you can only create 254 at a time (the 255th argument is the initial prefix argument). static() -------- Loading Loading
django/conf/urls/__init__.py +1 −18 Original line number Diff line number Diff line Loading @@ -10,7 +10,7 @@ from django.utils.deprecation import ( RemovedInDjango20Warning, RemovedInDjango110Warning, ) __all__ = ['handler400', 'handler403', 'handler404', 'handler500', 'include', 'patterns', 'url'] __all__ = ['handler400', 'handler403', 'handler404', 'handler500', 'include', 'url'] handler400 = 'django.views.defaults.bad_request' handler403 = 'django.views.defaults.permission_denied' Loading Loading @@ -76,23 +76,6 @@ def include(arg, namespace=None, app_name=None): return (urlconf_module, app_name, namespace) def patterns(prefix, *args): warnings.warn( 'django.conf.urls.patterns() is deprecated and will be removed in ' 'Django 1.10. Update your urlpatterns to be a list of ' 'django.conf.urls.url() instances instead.', RemovedInDjango110Warning, stacklevel=2 ) pattern_list = [] for t in args: if isinstance(t, (list, tuple)): t = url(prefix=prefix, *t) elif isinstance(t, RegexURLPattern): t.add_prefix(prefix) pattern_list.append(t) return pattern_list def url(regex, view, kwargs=None, name=None, prefix=''): if isinstance(view, (list, tuple)): # For include(...) processing. Loading
django/conf/urls/i18n.py +4 −19 Original line number Diff line number Diff line import warnings from django.conf import settings from django.conf.urls import patterns, url from django.conf.urls import url from django.core.urlresolvers import LocaleRegexURLResolver from django.utils import six from django.utils.deprecation import RemovedInDjango110Warning from django.views.i18n import set_language def i18n_patterns(prefix, *args): def i18n_patterns(*urls): """ Adds the language code prefix to every URL pattern within this function. This may only be used in the root URLconf, not in an included URLconf. """ if isinstance(prefix, six.string_types): warnings.warn( "Calling i18n_patterns() with the `prefix` argument and with tuples " "instead of django.conf.urls.url() instances is deprecated and " "will no longer work in Django 1.10. Use a list of " "django.conf.urls.url() instances instead.", RemovedInDjango110Warning, stacklevel=2 ) pattern_list = patterns(prefix, *args) else: pattern_list = [prefix] + list(args) if not settings.USE_I18N: return pattern_list return [LocaleRegexURLResolver(pattern_list)] return urls return [LocaleRegexURLResolver(list(urls))] urlpatterns = [ Loading
django/core/urlresolvers.py +0 −8 Original line number Diff line number Diff line Loading @@ -223,14 +223,6 @@ class RegexURLPattern(LocaleRegexProvider): def __repr__(self): return force_str('<%s %s %s>' % (self.__class__.__name__, self.name, self.regex.pattern)) def add_prefix(self, prefix): """ Adds the prefix string to a string-based callback. """ if not prefix or not hasattr(self, '_callback_str'): return self._callback_str = prefix + '.' + self._callback_str def resolve(self, path): match = self.regex.search(path) if match: Loading
docs/internals/deprecation.txt +1 −1 Original line number Diff line number Diff line Loading @@ -626,7 +626,7 @@ details on these changes. :mod:`django.contrib.gis.utils` will be removed. * ``django.conf.urls.defaults`` will be removed. The functions :func:`~django.conf.urls.include`, :func:`~django.conf.urls.patterns` and :func:`~django.conf.urls.include`, ``patterns()`` and :func:`~django.conf.urls.url` plus :data:`~django.conf.urls.handler404`, :data:`~django.conf.urls.handler500`, are now available through :mod:`django.conf.urls` . Loading
docs/ref/urls.txt +0 −71 Original line number Diff line number Diff line Loading @@ -4,77 +4,6 @@ .. module:: django.conf.urls patterns() ---------- .. function:: patterns(prefix, pattern_description, ...) .. deprecated:: 1.8 ``urlpatterns`` should be a plain list of :func:`django.conf.urls.url` instances instead. A function that takes a prefix, and an arbitrary number of URL patterns, and returns a list of URL patterns in the format Django needs. The first argument to ``patterns()`` is a string ``prefix``. Here's the example URLconf from the :doc:`Django overview </intro/overview>`:: from django.conf.urls import patterns, url urlpatterns = patterns('', url(r'^articles/([0-9]{4})/$', 'news.views.year_archive'), url(r'^articles/([0-9]{4})/([0-9]{2})/$', 'news.views.month_archive'), url(r'^articles/([0-9]{4})/([0-9]{2})/([0-9]+)/$', 'news.views.article_detail'), ) In this example, each view has a common prefix -- ``'news.views'``. Instead of typing that out for each entry in ``urlpatterns``, you can use the first argument to the ``patterns()`` function to specify a prefix to apply to each view function. With this in mind, the above example can be written more concisely as:: from django.conf.urls import patterns, url urlpatterns = patterns('news.views', url(r'^articles/([0-9]{4})/$', 'year_archive'), url(r'^articles/([0-9]{4})/([0-9]{2})/$', 'month_archive'), url(r'^articles/([0-9]{4})/([0-9]{2})/([0-9]+)/$', 'article_detail'), ) Note that you don't put a trailing dot (``"."``) in the prefix. Django puts that in automatically. The remaining arguments should be tuples in this format:: (regular expression, Python callback function [, optional_dictionary [, optional_name]]) The ``optional_dictionary`` and ``optional_name`` parameters are described in :ref:`Passing extra options to view functions <views-extra-options>`. .. note:: Because ``patterns()`` is a function call, it accepts a maximum of 255 arguments (URL patterns, in this case). This is a limit for all Python function calls. This is rarely a problem in practice, because you'll typically structure your URL patterns modularly by using ``include()`` sections. However, on the off-chance you do hit the 255-argument limit, realize that ``patterns()`` returns a Python list, so you can split up the construction of the list. :: urlpatterns = patterns('', ... ) urlpatterns += patterns('', ... ) Python lists have unlimited size, so there's no limit to how many URL patterns you can construct. The only limit is that you can only create 254 at a time (the 255th argument is the initial prefix argument). static() -------- Loading