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
|
@ -38,11 +38,11 @@ URLconf. If you're only changing a few simple attributes on a class-based view,
|
|||
you can simply pass them into the
|
||||
:meth:`~django.views.generic.base.View.as_view` method call itself::
|
||||
|
||||
from django.conf.urls import url
|
||||
from django.urls import path
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^about/$', TemplateView.as_view(template_name="about.html")),
|
||||
path('about/', TemplateView.as_view(template_name="about.html")),
|
||||
]
|
||||
|
||||
Any arguments passed to :meth:`~django.views.generic.base.View.as_view` will
|
||||
|
@ -75,11 +75,11 @@ class method instead, which provides a function-like entry to class-based
|
|||
views::
|
||||
|
||||
# urls.py
|
||||
from django.conf.urls import url
|
||||
from django.urls import path
|
||||
from some_app.views import AboutView
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^about/$', AboutView.as_view()),
|
||||
path('about/', AboutView.as_view()),
|
||||
]
|
||||
|
||||
|
||||
|
@ -100,11 +100,11 @@ preferable to ask the API when the most recent book was published.
|
|||
|
||||
We map the URL to book list view in the URLconf::
|
||||
|
||||
from django.conf.urls import url
|
||||
from django.urls import path
|
||||
from books.views import BookListView
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^books/$', BookListView.as_view()),
|
||||
path('books/', BookListView.as_view()),
|
||||
]
|
||||
|
||||
And the view::
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue