diff options
| author | Sjoerd Job Postmus <sjoerdjob@sjec.nl> | 2016-10-20 19:29:04 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-09-20 18:04:42 -0400 |
| commit | df41b5a05d4e00e80e73afe629072e37873e767a (patch) | |
| tree | baaf71ae695e2d3af604ea0d663284cb406c71e4 /docs/releases/2.0.txt | |
| parent | c4c128d67c7dc2830631c6859a204c9d259f1fb1 (diff) | |
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.
Diffstat (limited to 'docs/releases/2.0.txt')
| -rw-r--r-- | docs/releases/2.0.txt | 26 |
1 files changed, 26 insertions, 0 deletions
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<year>[0-9]{4})/$', views.year_archive), + +could be written as:: + + path('articles/<int:year>/', 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`` --------------------------------- |
