Refs #31534 -- Removed django.conf.urls.url() per deprecation timeline.
This commit is contained in:
parent
be6e468130
commit
98ae3925e5
|
@ -1,22 +1,9 @@
|
|||
import warnings
|
||||
|
||||
from django.urls import include, re_path
|
||||
from django.utils.deprecation import RemovedInDjango40Warning
|
||||
from django.urls import include
|
||||
from django.views import defaults
|
||||
|
||||
__all__ = ['handler400', 'handler403', 'handler404', 'handler500', 'include', 'url']
|
||||
__all__ = ['handler400', 'handler403', 'handler404', 'handler500', 'include']
|
||||
|
||||
handler400 = defaults.bad_request
|
||||
handler403 = defaults.permission_denied
|
||||
handler404 = defaults.page_not_found
|
||||
handler500 = defaults.server_error
|
||||
|
||||
|
||||
def url(regex, view, kwargs=None, name=None):
|
||||
warnings.warn(
|
||||
'django.conf.urls.url() is deprecated in favor of '
|
||||
'django.urls.re_path().',
|
||||
RemovedInDjango40Warning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return re_path(regex, view, kwargs, name)
|
||||
|
|
|
@ -136,17 +136,6 @@ Helper function to return a URL pattern for serving files in debug mode::
|
|||
# ... the rest of your URLconf goes here ...
|
||||
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
|
||||
``url()``
|
||||
=========
|
||||
|
||||
.. function:: url(regex, view, kwargs=None, name=None)
|
||||
|
||||
This function is an alias to :func:`django.urls.re_path()`.
|
||||
|
||||
.. deprecated:: 3.1
|
||||
|
||||
Alias of :func:`django.urls.re_path` for backwards compatibility.
|
||||
|
||||
``handler400``
|
||||
==============
|
||||
|
||||
|
|
|
@ -311,3 +311,5 @@ to remove usage of these features.
|
|||
|
||||
* The ``NullBooleanField`` model field is removed, except for support in
|
||||
historical migrations.
|
||||
|
||||
* ``django.conf.urls.url()`` is removed.
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
import string
|
||||
import uuid
|
||||
|
||||
from django.conf.urls import url as conf_url
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.test import SimpleTestCase
|
||||
from django.test.utils import override_settings
|
||||
from django.urls import NoReverseMatch, Resolver404, path, resolve, reverse
|
||||
from django.utils.deprecation import RemovedInDjango40Warning
|
||||
|
||||
from .converters import DynamicConverter
|
||||
from .views import empty_view
|
||||
|
@ -315,13 +313,3 @@ class ConversionExceptionTests(SimpleTestCase):
|
|||
raise TypeError('This type error propagates.')
|
||||
with self.assertRaisesMessage(TypeError, 'This type error propagates.'):
|
||||
reverse('dynamic', kwargs={'value': object()})
|
||||
|
||||
|
||||
class DeprecationTests(SimpleTestCase):
|
||||
def test_url_warning(self):
|
||||
msg = (
|
||||
'django.conf.urls.url() is deprecated in favor of '
|
||||
'django.urls.re_path().'
|
||||
)
|
||||
with self.assertRaisesMessage(RemovedInDjango40Warning, msg):
|
||||
conf_url(r'^regex/(?P<pk>[0-9]+)/$', empty_view, name='regex')
|
||||
|
|
Loading…
Reference in New Issue