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/2.0.txt | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'docs/releases/2.0.txt') 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