mirror of
https://github.com/django/django.git
synced 2025-08-04 19:08:28 +00:00
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:
parent
c4c128d67c
commit
df41b5a05d
77 changed files with 1663 additions and 1105 deletions
|
@ -89,11 +89,11 @@ request to a matching method if one is defined, or raises
|
|||
:class:`~django.http.HttpResponseNotAllowed` if not::
|
||||
|
||||
# urls.py
|
||||
from django.conf.urls import url
|
||||
from django.urls import path
|
||||
from myapp.views import MyView
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^about/$', MyView.as_view()),
|
||||
path('about/', MyView.as_view()),
|
||||
]
|
||||
|
||||
|
||||
|
@ -130,7 +130,7 @@ Another option is to configure class attributes as keyword arguments to the
|
|||
:meth:`~django.views.generic.base.View.as_view` call in the URLconf::
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^about/$', GreetingView.as_view(greeting="G'day")),
|
||||
path('about/', GreetingView.as_view(greeting="G'day")),
|
||||
]
|
||||
|
||||
.. note::
|
||||
|
@ -245,8 +245,8 @@ The easiest place to do this is in the URLconf where you deploy your view::
|
|||
from .views import VoteView
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^about/$', login_required(TemplateView.as_view(template_name="secret.html"))),
|
||||
url(r'^vote/$', permission_required('polls.can_vote')(VoteView.as_view())),
|
||||
path('about/', login_required(TemplateView.as_view(template_name="secret.html"))),
|
||||
path('vote/', permission_required('polls.can_vote')(VoteView.as_view())),
|
||||
]
|
||||
|
||||
This approach applies the decorator on a per-instance basis. If you
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue