From df41b5a05d4e00e80e73afe629072e37873e767a Mon Sep 17 00:00:00 2001 From: Sjoerd Job Postmus Date: Thu, 20 Oct 2016 19:29:04 +0200 Subject: Fixed #28593 -- Added a simplified URL routing syntax per DEP 0201. Thanks Aymeric Augustin for shepherding the DEP and patch review. Thanks Marten Kenbeek and Tim Graham for contributing to the code. Thanks Tom Christie, Shai Berger, and Tim Graham for the docs. --- docs/releases/1.4.txt | 5 ++--- docs/releases/1.9.txt | 6 +++--- docs/releases/2.0.txt | 26 ++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 6 deletions(-) (limited to 'docs/releases') diff --git a/docs/releases/1.4.txt b/docs/releases/1.4.txt index 3a8b52db57..13cff1f0b3 100644 --- a/docs/releases/1.4.txt +++ b/docs/releases/1.4.txt @@ -1229,9 +1229,8 @@ disable this backward-compatibility shim and deprecation warning. ``django.conf.urls.defaults`` ----------------------------- -Until Django 1.3, the functions :func:`~django.conf.urls.include`, -``patterns()`` and :func:`~django.conf.urls.url` plus -:data:`~django.conf.urls.handler404`, :data:`~django.conf.urls.handler500` +Until Django 1.3, the ``include()``, ``patterns()``, and ``url()`` functions, +plus :data:`~django.conf.urls.handler404` and :data:`~django.conf.urls.handler500` were located in a ``django.conf.urls.defaults`` module. In Django 1.4, they live in :mod:`django.conf.urls`. diff --git a/docs/releases/1.9.txt b/docs/releases/1.9.txt index 9d0d9efd93..2b012191cd 100644 --- a/docs/releases/1.9.txt +++ b/docs/releases/1.9.txt @@ -657,7 +657,7 @@ URLs * The application namespace can now be set using an ``app_name`` attribute on the included module or object. It can also be set by passing a 2-tuple of (, ) as the first argument to - :func:`~django.conf.urls.include`. + ``include()``. * System checks have been added for common URL pattern mistakes. @@ -1233,8 +1233,8 @@ extending. This change necessitated a new template loader API. The old Details about the new API can be found :ref:`in the template loader documentation `. -Passing a 3-tuple or an ``app_name`` to :func:`~django.conf.urls.include()` ---------------------------------------------------------------------------- +Passing a 3-tuple or an ``app_name`` to ``include()`` +----------------------------------------------------- The instance namespace part of passing a tuple as an argument to ``include()`` has been replaced by passing the ``namespace`` argument to ``include()``. For diff --git a/docs/releases/2.0.txt b/docs/releases/2.0.txt index b45e494800..457e69ea9e 100644 --- a/docs/releases/2.0.txt +++ b/docs/releases/2.0.txt @@ -46,6 +46,32 @@ be compatible with Django 2.0. What's new in Django 2.0 ======================== +Simplified URL routing syntax +----------------------------- + +The new :func:`django.urls.path()` function allows a simpler, more readable URL +routing syntax. For example, this example from previous Django releases:: + + url(r'^articles/(?P[0-9]{4})/$', views.year_archive), + +could be written as:: + + path('articles//', views.year_archive), + +The new syntax supports type coercion of URL parameters. In the example, the +view will receive the ``year`` keyword argument as an integer rather than as +a string. + +The ``django.conf.urls.url()`` function from previous versions is now available +as :func:`django.urls.re_path`, however, the old location remains for backwards +compatibility, without an imminent deprecation. The old +``django.conf.urls.include()`` function is now importable from ``django.urls`` +so you can use ``from django.urls import include, path, re_path`` in your +URLconfs. + +The :doc:`/topics/http/urls` document is rewritten to feature the new syntax +and provide more details. + Mobile-friendly ``contrib.admin`` --------------------------------- -- cgit v1.3