Refs #22218 -- Removed conf.urls.patterns() per deprecation timeline.
This commit is contained in:
parent
3f50dc2be5
commit
a25d3ce007
|
@ -10,7 +10,7 @@ from django.utils.deprecation import (
|
||||||
RemovedInDjango20Warning, RemovedInDjango110Warning,
|
RemovedInDjango20Warning, RemovedInDjango110Warning,
|
||||||
)
|
)
|
||||||
|
|
||||||
__all__ = ['handler400', 'handler403', 'handler404', 'handler500', 'include', 'patterns', 'url']
|
__all__ = ['handler400', 'handler403', 'handler404', 'handler500', 'include', 'url']
|
||||||
|
|
||||||
handler400 = 'django.views.defaults.bad_request'
|
handler400 = 'django.views.defaults.bad_request'
|
||||||
handler403 = 'django.views.defaults.permission_denied'
|
handler403 = 'django.views.defaults.permission_denied'
|
||||||
|
@ -76,23 +76,6 @@ def include(arg, namespace=None, app_name=None):
|
||||||
return (urlconf_module, app_name, namespace)
|
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=''):
|
def url(regex, view, kwargs=None, name=None, prefix=''):
|
||||||
if isinstance(view, (list, tuple)):
|
if isinstance(view, (list, tuple)):
|
||||||
# For include(...) processing.
|
# For include(...) processing.
|
||||||
|
|
|
@ -1,33 +1,18 @@
|
||||||
import warnings
|
|
||||||
|
|
||||||
from django.conf import settings
|
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.core.urlresolvers import LocaleRegexURLResolver
|
||||||
from django.utils import six
|
|
||||||
from django.utils.deprecation import RemovedInDjango110Warning
|
|
||||||
from django.views.i18n import set_language
|
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
|
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
|
function. This may only be used in the root URLconf, not in an included
|
||||||
URLconf.
|
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:
|
if not settings.USE_I18N:
|
||||||
return pattern_list
|
return urls
|
||||||
return [LocaleRegexURLResolver(pattern_list)]
|
return [LocaleRegexURLResolver(list(urls))]
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
|
|
@ -223,14 +223,6 @@ class RegexURLPattern(LocaleRegexProvider):
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return force_str('<%s %s %s>' % (self.__class__.__name__, self.name, self.regex.pattern))
|
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):
|
def resolve(self, path):
|
||||||
match = self.regex.search(path)
|
match = self.regex.search(path)
|
||||||
if match:
|
if match:
|
||||||
|
|
|
@ -626,7 +626,7 @@ details on these changes.
|
||||||
:mod:`django.contrib.gis.utils` will be removed.
|
:mod:`django.contrib.gis.utils` will be removed.
|
||||||
|
|
||||||
* ``django.conf.urls.defaults`` will be removed. The functions
|
* ``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`,
|
:func:`~django.conf.urls.url` plus :data:`~django.conf.urls.handler404`,
|
||||||
:data:`~django.conf.urls.handler500`, are now available through
|
:data:`~django.conf.urls.handler500`, are now available through
|
||||||
:mod:`django.conf.urls` .
|
:mod:`django.conf.urls` .
|
||||||
|
|
|
@ -4,77 +4,6 @@
|
||||||
|
|
||||||
.. module:: django.conf.urls
|
.. 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()
|
static()
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
|
|
@ -1233,7 +1233,7 @@ disable this backward-compatibility shim and deprecation warning.
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Until Django 1.3, the functions :func:`~django.conf.urls.include`,
|
Until Django 1.3, the functions :func:`~django.conf.urls.include`,
|
||||||
:func:`~django.conf.urls.patterns` and :func:`~django.conf.urls.url` plus
|
``patterns()`` and :func:`~django.conf.urls.url` plus
|
||||||
:data:`~django.conf.urls.handler404`, :data:`~django.conf.urls.handler500`
|
:data:`~django.conf.urls.handler404`, :data:`~django.conf.urls.handler500`
|
||||||
were located in a ``django.conf.urls.defaults`` module.
|
were located in a ``django.conf.urls.defaults`` module.
|
||||||
|
|
||||||
|
|
|
@ -1332,13 +1332,7 @@ Django provides two mechanisms to internationalize URL patterns:
|
||||||
Language prefix in URL patterns
|
Language prefix in URL patterns
|
||||||
-------------------------------
|
-------------------------------
|
||||||
|
|
||||||
.. function:: i18n_patterns(prefix, pattern_description, ...)
|
.. function:: i18n_patterns(*pattern_list)
|
||||||
|
|
||||||
.. deprecated:: 1.8
|
|
||||||
|
|
||||||
The ``prefix`` argument to ``i18n_patterns()`` has been deprecated and will
|
|
||||||
not be supported in Django 1.10. Simply pass a list of
|
|
||||||
:func:`django.conf.urls.url` instances instead.
|
|
||||||
|
|
||||||
This function can be used in your root URLconf and Django will automatically
|
This function can be used in your root URLconf and Django will automatically
|
||||||
prepend the current active language code to all url patterns defined within
|
prepend the current active language code to all url patterns defined within
|
||||||
|
|
|
@ -1,16 +1,11 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.conf.urls import url
|
||||||
from django.conf.urls.i18n import i18n_patterns
|
from django.conf.urls.i18n import i18n_patterns
|
||||||
from django.http import HttpResponse, StreamingHttpResponse
|
from django.http import HttpResponse, StreamingHttpResponse
|
||||||
from django.test import ignore_warnings
|
|
||||||
from django.utils.deprecation import RemovedInDjango110Warning
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
# test deprecated version of i18n_patterns() function (with prefix). Remove it
|
urlpatterns = i18n_patterns(
|
||||||
# and convert to list of urls() in Django 1.10
|
url(r'^simple/$', lambda r: HttpResponse()),
|
||||||
i18n_patterns = ignore_warnings(category=RemovedInDjango110Warning)(i18n_patterns)
|
url(r'^streaming/$', lambda r: StreamingHttpResponse([_("Yes"), "/", _("No")])),
|
||||||
|
|
||||||
urlpatterns = i18n_patterns('',
|
|
||||||
(r'^simple/$', lambda r: HttpResponse()),
|
|
||||||
(r'^streaming/$', lambda r: StreamingHttpResponse([_("Yes"), "/", _("No")])),
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,31 +1,24 @@
|
||||||
import warnings
|
from django.conf.urls import include, url
|
||||||
|
|
||||||
from django.conf.urls import include, patterns, url
|
|
||||||
from django.utils.deprecation import RemovedInDjango110Warning
|
|
||||||
|
|
||||||
from .namespace_urls import URLObject
|
from .namespace_urls import URLObject
|
||||||
from .views import view_class_instance
|
from .views import empty_view, view_class_instance
|
||||||
|
|
||||||
testobj3 = URLObject('testapp', 'test-ns3')
|
testobj3 = URLObject('testapp', 'test-ns3')
|
||||||
testobj4 = URLObject('testapp', 'test-ns4')
|
testobj4 = URLObject('testapp', 'test-ns4')
|
||||||
|
|
||||||
# test deprecated patterns() function. convert to list of urls() in Django 1.10
|
urlpatterns = [
|
||||||
with warnings.catch_warnings():
|
url(r'^normal/$', empty_view, name='inc-normal-view'),
|
||||||
warnings.filterwarnings('ignore', category=RemovedInDjango110Warning)
|
url(r'^normal/(?P<arg1>[0-9]+)/(?P<arg2>[0-9]+)/$', empty_view, name='inc-normal-view'),
|
||||||
|
|
||||||
urlpatterns = patterns('urlpatterns_reverse.views',
|
url(r'^\+\\\$\*/$', empty_view, name='inc-special-view'),
|
||||||
url(r'^normal/$', 'empty_view', name='inc-normal-view'),
|
|
||||||
url(r'^normal/(?P<arg1>[0-9]+)/(?P<arg2>[0-9]+)/$', 'empty_view', name='inc-normal-view'),
|
|
||||||
|
|
||||||
url(r'^\+\\\$\*/$', 'empty_view', name='inc-special-view'),
|
url(r'^mixed_args/([0-9]+)/(?P<arg2>[0-9]+)/$', empty_view, name='inc-mixed-args'),
|
||||||
|
url(r'^no_kwargs/([0-9]+)/([0-9]+)/$', empty_view, name='inc-no-kwargs'),
|
||||||
|
|
||||||
url(r'^mixed_args/([0-9]+)/(?P<arg2>[0-9]+)/$', 'empty_view', name='inc-mixed-args'),
|
url(r'^view_class/(?P<arg1>[0-9]+)/(?P<arg2>[0-9]+)/$', view_class_instance, name='inc-view-class'),
|
||||||
url(r'^no_kwargs/([0-9]+)/([0-9]+)/$', 'empty_view', name='inc-no-kwargs'),
|
|
||||||
|
|
||||||
url(r'^view_class/(?P<arg1>[0-9]+)/(?P<arg2>[0-9]+)/$', view_class_instance, name='inc-view-class'),
|
url(r'^test3/', include(testobj3.urls)),
|
||||||
|
url(r'^test4/', include(testobj4.urls)),
|
||||||
(r'^test3/', include(testobj3.urls)),
|
url(r'^ns-included3/', include('urlpatterns_reverse.included_urls', namespace='inc-ns3')),
|
||||||
(r'^test4/', include(testobj4.urls)),
|
url(r'^ns-included4/', include('urlpatterns_reverse.namespace_urls', namespace='inc-ns4')),
|
||||||
(r'^ns-included3/', include('urlpatterns_reverse.included_urls', namespace='inc-ns3')),
|
]
|
||||||
(r'^ns-included4/', include('urlpatterns_reverse.namespace_urls', namespace='inc-ns4')),
|
|
||||||
)
|
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
import warnings
|
from django.conf.urls import include, url
|
||||||
|
|
||||||
from django.conf.urls import include, patterns, url
|
|
||||||
from django.utils.deprecation import RemovedInDjango110Warning
|
|
||||||
|
|
||||||
from .views import (
|
from .views import (
|
||||||
absolute_kwargs_view, defaults_view, empty_view, empty_view_partial,
|
absolute_kwargs_view, defaults_view, empty_view, empty_view_partial,
|
||||||
empty_view_wrapped, nested_view,
|
empty_view_wrapped, kwargs_view, nested_view,
|
||||||
)
|
)
|
||||||
|
|
||||||
other_patterns = [
|
other_patterns = [
|
||||||
|
@ -13,79 +10,75 @@ other_patterns = [
|
||||||
url(r'nested_path/$', nested_view),
|
url(r'nested_path/$', nested_view),
|
||||||
]
|
]
|
||||||
|
|
||||||
# test deprecated patterns() function. convert to list of urls() in Django 1.10
|
urlpatterns = [
|
||||||
with warnings.catch_warnings():
|
url(r'^places/([0-9]+)/$', empty_view, name='places'),
|
||||||
warnings.filterwarnings('ignore', category=RemovedInDjango110Warning)
|
url(r'^places?/$', empty_view, name="places?"),
|
||||||
|
url(r'^places+/$', empty_view, name="places+"),
|
||||||
|
url(r'^places*/$', empty_view, name="places*"),
|
||||||
|
url(r'^(?:places/)?$', empty_view, name="places2?"),
|
||||||
|
url(r'^(?:places/)+$', empty_view, name="places2+"),
|
||||||
|
url(r'^(?:places/)*$', empty_view, name="places2*"),
|
||||||
|
url(r'^places/([0-9]+|[a-z_]+)/', empty_view, name="places3"),
|
||||||
|
url(r'^places/(?P<id>[0-9]+)/$', empty_view, name="places4"),
|
||||||
|
url(r'^people/(?P<name>\w+)/$', empty_view, name="people"),
|
||||||
|
url(r'^people/(?:name/)', empty_view, name="people2"),
|
||||||
|
url(r'^people/(?:name/(\w+)/)?', empty_view, name="people2a"),
|
||||||
|
url(r'^people/(?P<name>\w+)-(?P=name)/$', empty_view, name="people_backref"),
|
||||||
|
url(r'^optional/(?P<name>.*)/(?:.+/)?', empty_view, name="optional"),
|
||||||
|
url(r'^optional/(?P<arg1>\d+)/(?:(?P<arg2>\d+)/)?', absolute_kwargs_view, name="named_optional"),
|
||||||
|
url(r'^optional/(?P<arg1>\d+)/(?:(?P<arg2>\d+)/)?$', absolute_kwargs_view, name="named_optional_terminated"),
|
||||||
|
url(r'^nested/noncapture/(?:(?P<p>\w+))$', empty_view, name='nested-noncapture'),
|
||||||
|
url(r'^nested/capture/((\w+)/)?$', empty_view, name='nested-capture'),
|
||||||
|
url(r'^nested/capture/mixed/((?P<p>\w+))$', empty_view, name='nested-mixedcapture'),
|
||||||
|
url(r'^nested/capture/named/(?P<outer>(?P<inner>\w+)/)?$', empty_view, name='nested-namedcapture'),
|
||||||
|
url(r'^hardcoded/$', empty_view, name="hardcoded"),
|
||||||
|
url(r'^hardcoded/doc\.pdf$', empty_view, name="hardcoded2"),
|
||||||
|
url(r'^people/(?P<state>\w\w)/(?P<name>\w+)/$', empty_view, name="people3"),
|
||||||
|
url(r'^people/(?P<state>\w\w)/(?P<name>[0-9])/$', empty_view, name="people4"),
|
||||||
|
url(r'^people/((?P<state>\w\w)/test)?/(\w+)/$', empty_view, name="people6"),
|
||||||
|
url(r'^character_set/[abcdef0-9]/$', empty_view, name="range"),
|
||||||
|
url(r'^character_set/[\w]/$', empty_view, name="range2"),
|
||||||
|
url(r'^price/\$([0-9]+)/$', empty_view, name="price"),
|
||||||
|
url(r'^price/[$]([0-9]+)/$', empty_view, name="price2"),
|
||||||
|
url(r'^price/[\$]([0-9]+)/$', empty_view, name="price3"),
|
||||||
|
url(r'^product/(?P<product>\w+)\+\(\$(?P<price>[0-9]+(\.[0-9]+)?)\)/$', empty_view, name="product"),
|
||||||
|
url(r'^headlines/(?P<year>[0-9]+)\.(?P<month>[0-9]+)\.(?P<day>[0-9]+)/$', empty_view, name="headlines"),
|
||||||
|
url(r'^windows_path/(?P<drive_name>[A-Z]):\\(?P<path>.+)/$', empty_view, name="windows"),
|
||||||
|
url(r'^special_chars/(?P<chars>.+)/$', empty_view, name="special"),
|
||||||
|
url(r'^(?P<name>.+)/[0-9]+/$', empty_view, name="mixed"),
|
||||||
|
url(r'^repeats/a{1,2}/$', empty_view, name="repeats"),
|
||||||
|
url(r'^repeats/a{2,4}/$', empty_view, name="repeats2"),
|
||||||
|
url(r'^repeats/a{2}/$', empty_view, name="repeats3"),
|
||||||
|
url(r'^(?i)CaseInsensitive/(\w+)', empty_view, name="insensitive"),
|
||||||
|
url(r'^test/1/?', empty_view, name="test"),
|
||||||
|
url(r'^(?i)test/2/?$', empty_view, name="test2"),
|
||||||
|
url(r'^outer/(?P<outer>[0-9]+)/', include('urlpatterns_reverse.included_urls')),
|
||||||
|
url(r'^outer-no-kwargs/([0-9]+)/', include('urlpatterns_reverse.included_no_kwargs_urls')),
|
||||||
|
url('', include('urlpatterns_reverse.extra_urls')),
|
||||||
|
url(r'^lookahead-/(?!not-a-city)(?P<city>[^/]+)/$', empty_view, name='lookahead-negative'),
|
||||||
|
url(r'^lookahead\+/(?=a-city)(?P<city>[^/]+)/$', empty_view, name='lookahead-positive'),
|
||||||
|
url(r'^lookbehind-/(?P<city>[^/]+)(?<!not-a-city)/$', empty_view, name='lookbehind-negative'),
|
||||||
|
url(r'^lookbehind\+/(?P<city>[^/]+)(?<=a-city)/$', empty_view, name='lookbehind-positive'),
|
||||||
|
|
||||||
urlpatterns = patterns('',
|
# Partials should be fine.
|
||||||
url(r'^places/([0-9]+)/$', empty_view, name='places'),
|
url(r'^partial/', empty_view_partial, name="partial"),
|
||||||
url(r'^places?/$', empty_view, name="places?"),
|
url(r'^partial_wrapped/', empty_view_wrapped, name="partial_wrapped"),
|
||||||
url(r'^places+/$', empty_view, name="places+"),
|
|
||||||
url(r'^places*/$', empty_view, name="places*"),
|
|
||||||
url(r'^(?:places/)?$', empty_view, name="places2?"),
|
|
||||||
url(r'^(?:places/)+$', empty_view, name="places2+"),
|
|
||||||
url(r'^(?:places/)*$', empty_view, name="places2*"),
|
|
||||||
url(r'^places/([0-9]+|[a-z_]+)/', empty_view, name="places3"),
|
|
||||||
url(r'^places/(?P<id>[0-9]+)/$', empty_view, name="places4"),
|
|
||||||
url(r'^people/(?P<name>\w+)/$', empty_view, name="people"),
|
|
||||||
url(r'^people/(?:name/)', empty_view, name="people2"),
|
|
||||||
url(r'^people/(?:name/(\w+)/)?', empty_view, name="people2a"),
|
|
||||||
url(r'^people/(?P<name>\w+)-(?P=name)/$', empty_view, name="people_backref"),
|
|
||||||
url(r'^optional/(?P<name>.*)/(?:.+/)?', empty_view, name="optional"),
|
|
||||||
url(r'^optional/(?P<arg1>\d+)/(?:(?P<arg2>\d+)/)?', absolute_kwargs_view, name="named_optional"),
|
|
||||||
url(r'^optional/(?P<arg1>\d+)/(?:(?P<arg2>\d+)/)?$', absolute_kwargs_view, name="named_optional_terminated"),
|
|
||||||
url(r'^nested/noncapture/(?:(?P<p>\w+))$', empty_view, name='nested-noncapture'),
|
|
||||||
url(r'^nested/capture/((\w+)/)?$', empty_view, name='nested-capture'),
|
|
||||||
url(r'^nested/capture/mixed/((?P<p>\w+))$', empty_view, name='nested-mixedcapture'),
|
|
||||||
url(r'^nested/capture/named/(?P<outer>(?P<inner>\w+)/)?$', empty_view, name='nested-namedcapture'),
|
|
||||||
url(r'^hardcoded/$', empty_view, name="hardcoded"),
|
|
||||||
url(r'^hardcoded/doc\.pdf$', empty_view, name="hardcoded2"),
|
|
||||||
url(r'^people/(?P<state>\w\w)/(?P<name>\w+)/$', empty_view, name="people3"),
|
|
||||||
url(r'^people/(?P<state>\w\w)/(?P<name>[0-9])/$', empty_view, name="people4"),
|
|
||||||
url(r'^people/((?P<state>\w\w)/test)?/(\w+)/$', empty_view, name="people6"),
|
|
||||||
url(r'^character_set/[abcdef0-9]/$', empty_view, name="range"),
|
|
||||||
url(r'^character_set/[\w]/$', empty_view, name="range2"),
|
|
||||||
url(r'^price/\$([0-9]+)/$', empty_view, name="price"),
|
|
||||||
url(r'^price/[$]([0-9]+)/$', empty_view, name="price2"),
|
|
||||||
url(r'^price/[\$]([0-9]+)/$', empty_view, name="price3"),
|
|
||||||
url(r'^product/(?P<product>\w+)\+\(\$(?P<price>[0-9]+(\.[0-9]+)?)\)/$', empty_view, name="product"),
|
|
||||||
url(r'^headlines/(?P<year>[0-9]+)\.(?P<month>[0-9]+)\.(?P<day>[0-9]+)/$', empty_view, name="headlines"),
|
|
||||||
url(r'^windows_path/(?P<drive_name>[A-Z]):\\(?P<path>.+)/$', empty_view, name="windows"),
|
|
||||||
url(r'^special_chars/(?P<chars>.+)/$', empty_view, name="special"),
|
|
||||||
url(r'^(?P<name>.+)/[0-9]+/$', empty_view, name="mixed"),
|
|
||||||
url(r'^repeats/a{1,2}/$', empty_view, name="repeats"),
|
|
||||||
url(r'^repeats/a{2,4}/$', empty_view, name="repeats2"),
|
|
||||||
url(r'^repeats/a{2}/$', empty_view, name="repeats3"),
|
|
||||||
url(r'^(?i)CaseInsensitive/(\w+)', empty_view, name="insensitive"),
|
|
||||||
url(r'^test/1/?', empty_view, name="test"),
|
|
||||||
url(r'^(?i)test/2/?$', empty_view, name="test2"),
|
|
||||||
url(r'^outer/(?P<outer>[0-9]+)/', include('urlpatterns_reverse.included_urls')),
|
|
||||||
url(r'^outer-no-kwargs/([0-9]+)/', include('urlpatterns_reverse.included_no_kwargs_urls')),
|
|
||||||
url('', include('urlpatterns_reverse.extra_urls')),
|
|
||||||
url(r'^lookahead-/(?!not-a-city)(?P<city>[^/]+)/$', empty_view, name='lookahead-negative'),
|
|
||||||
url(r'^lookahead\+/(?=a-city)(?P<city>[^/]+)/$', empty_view, name='lookahead-positive'),
|
|
||||||
url(r'^lookbehind-/(?P<city>[^/]+)(?<!not-a-city)/$', empty_view, name='lookbehind-negative'),
|
|
||||||
url(r'^lookbehind\+/(?P<city>[^/]+)(?<=a-city)/$', empty_view, name='lookbehind-positive'),
|
|
||||||
|
|
||||||
# Partials should be fine.
|
# This is non-reversible, but we shouldn't blow up when parsing it.
|
||||||
url(r'^partial/', empty_view_partial, name="partial"),
|
url(r'^(?:foo|bar)(\w+)/$', empty_view, name="disjunction"),
|
||||||
url(r'^partial_wrapped/', empty_view_wrapped, name="partial_wrapped"),
|
|
||||||
|
|
||||||
# This is non-reversible, but we shouldn't blow up when parsing it.
|
# Regression views for #9038. See tests for more details
|
||||||
url(r'^(?:foo|bar)(\w+)/$', empty_view, name="disjunction"),
|
url(r'arg_view/$', kwargs_view),
|
||||||
|
url(r'arg_view/(?P<arg1>[0-9]+)/$', kwargs_view),
|
||||||
|
url(r'absolute_arg_view/(?P<arg1>[0-9]+)/$', absolute_kwargs_view),
|
||||||
|
url(r'absolute_arg_view/$', absolute_kwargs_view),
|
||||||
|
|
||||||
# Regression views for #9038. See tests for more details
|
# Tests for #13154. Mixed syntax to test both ways of defining URLs.
|
||||||
url(r'arg_view/$', 'urlpatterns_reverse.views.kwargs_view'),
|
url(r'defaults_view1/(?P<arg1>[0-9]+)/', defaults_view, {'arg2': 1}, name='defaults'),
|
||||||
url(r'arg_view/(?P<arg1>[0-9]+)/$', 'urlpatterns_reverse.views.kwargs_view'),
|
url(r'defaults_view2/(?P<arg1>[0-9]+)/', defaults_view, {'arg2': 2}, 'defaults'),
|
||||||
url(r'absolute_arg_view/(?P<arg1>[0-9]+)/$', absolute_kwargs_view),
|
|
||||||
url(r'absolute_arg_view/$', absolute_kwargs_view),
|
|
||||||
|
|
||||||
# Tests for #13154. Mixed syntax to test both ways of defining URLs.
|
url('^includes/', include(other_patterns)),
|
||||||
url(r'defaults_view1/(?P<arg1>[0-9]+)/', defaults_view, {'arg2': 1}, name='defaults'),
|
|
||||||
(r'defaults_view2/(?P<arg1>[0-9]+)/', defaults_view, {'arg2': 2}, 'defaults'),
|
|
||||||
|
|
||||||
url('^includes/', include(other_patterns)),
|
# Security tests
|
||||||
|
url('(.+)/security/$', empty_view, name='security'),
|
||||||
# Security tests
|
]
|
||||||
url('(.+)/security/$', empty_view, name='security'),
|
|
||||||
)
|
|
||||||
|
|
Loading…
Reference in New Issue