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.
This commit is contained in:
Sjoerd Job Postmus 2016-10-20 19:29:04 +02:00 committed by Tim Graham
parent c4c128d67c
commit df41b5a05d
77 changed files with 1663 additions and 1105 deletions

View file

@ -47,7 +47,7 @@ Then either:
3. Add an entry in your URLconf. For example::
urlpatterns = [
url(r'^pages/', include('django.contrib.flatpages.urls')),
path('pages/', include('django.contrib.flatpages.urls')),
]
or:
@ -74,7 +74,7 @@ There are several ways to include the flat pages in your URLconf. You can
dedicate a particular path to flat pages::
urlpatterns = [
url(r'^pages/', include('django.contrib.flatpages.urls')),
path('pages/', include('django.contrib.flatpages.urls')),
]
You can also set it up as a "catchall" pattern. In this case, it is important
@ -84,7 +84,7 @@ to place the pattern at the end of the other urlpatterns::
# Your other patterns here
urlpatterns += [
url(r'^(?P<url>.*/)$', views.flatpage),
path('<path:url>', views.flatpage),
]
.. warning::
@ -100,8 +100,8 @@ tag::
from django.contrib.flatpages import views
urlpatterns += [
url(r'^about-us/$', views.flatpage, {'url': '/about-us/'}, name='about'),
url(r'^license/$', views.flatpage, {'url': '/license/'}, name='license'),
path('about-us/', views.flatpage, {'url': '/about-us/'}, name='about'),
path('license/', views.flatpage, {'url': '/license/'}, name='license'),
]
Using the middleware
@ -345,15 +345,15 @@ Example
Here's an example of a URLconf using :class:`FlatPageSitemap`::
from django.conf.urls import url
from django.contrib.flatpages.sitemaps import FlatPageSitemap
from django.contrib.sitemaps.views import sitemap
from django.urls import path
urlpatterns = [
# ...
# the sitemap
url(r'^sitemap\.xml$', sitemap,
path('sitemap.xml', sitemap,
{'sitemaps': {'flatpages': FlatPageSitemap}},
name='django.contrib.sitemaps.views.sitemap'),
]