Skip to content

Commit 08c5102

Browse files
committed
use path funcion instead of url funcion
1 parent 49b579d commit 08c5102

File tree

5 files changed

+15
-16
lines changed

5 files changed

+15
-16
lines changed

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,14 @@ Hooking it up:
134134
.. code:: python
135135
136136
# api/urls.py
137-
from django.conf.urls.default import url, include
137+
from django.urls import include, path
138138
139139
from posts.api import PostResource
140140
141141
urlpatterns = [
142142
# The usual suspects, then...
143143
144-
url(r'^api/posts/', include(PostResource.urls())),
144+
path('api/posts/', include(PostResource.urls())),
145145
]
146146
147147

docs/extending.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Finally, it's just a matter of hooking up the URLs as well. You can do this
9292
manually or (once again) by extending a built-in method.::
9393

9494
# Add the correct import here.
95-
from django.conf.urls import url
95+
from django.urls import path
9696

9797
from restless.dj import DjangoResource
9898
from restless.resources import skip_prepare
@@ -129,7 +129,7 @@ manually or (once again) by extending a built-in method.::
129129
def urls(cls, name_prefix=None):
130130
urlpatterns = super(PostResource, cls).urls(name_prefix=name_prefix)
131131
return [
132-
url(r'^schema/$', cls.as_view('schema'), name=cls.build_url_name('schema', name_prefix)),
132+
path('schema/', cls.as_view('schema'), name=cls.build_url_name('schema', name_prefix)),
133133
] + urlpatterns
134134

135135
.. note::
@@ -575,4 +575,3 @@ user provides a ``?format=yaml`` GET param...::
575575
return json.dumps(body, cls=MoreTypesJSONEncoder)
576576

577577
.. _`a host of problems`: https://pypi.python.org/pypi/defusedxml
578-

docs/tutorial.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ practice would be to create a URLconf just for the API portion of your site.::
260260

261261
# The ``settings.ROOT_URLCONF`` file
262262
# myproject/urls.py
263-
from django.conf.urls import url, include
263+
from django.urls import path, include
264264

265265
# Add this!
266266
from posts.api import PostResource
@@ -269,7 +269,7 @@ practice would be to create a URLconf just for the API portion of your site.::
269269
# The usual fare, then...
270270

271271
# Add this!
272-
url(r'api/posts/', include(PostResource.urls())),
272+
path('api/posts/', include(PostResource.urls())),
273273
]
274274

275275
Note that unlike some other CBVs (admin specifically), the ``urls`` here is a
@@ -284,8 +284,8 @@ You can also manually hook up URLs by specifying something like::
284284
# ...
285285

286286
# Identical to the above.
287-
url(r'api/posts/$', PostResource.as_list(), name='api_post_list'),
288-
url(r'api/posts/(?P<pk>\d+)/$', PostResource.as_detail(), name='api_post_detail'),
287+
path('api/posts/', PostResource.as_list(), name='api_post_list'),
288+
path('api/posts/<pk>/', PostResource.as_detail(), name='api_post_detail'),
289289
]
290290

291291

examples/django/posts/urls.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
from django.conf.urls import url, include
1+
from django.urls import path, include
22

33
from .api import PostResource
44

55

66
urlpatterns = [
7-
url(r'^posts/', include(PostResource.urls())),
7+
path('posts/', include(PostResource.urls())),
88

99
# Alternatively, if you don't like the defaults...
10-
# url(r'^posts/$', PostResource.as_list(), name='api_posts_list'),
11-
# url(r'^posts/(?P<pk>\d+)/$', PostResource.as_detail(), name='api_posts_detail'),
10+
# path('posts/', PostResource.as_list(), name='api_posts_list'),
11+
# path('posts/<pk>/', PostResource.as_detail(), name='api_posts_detail'),
1212
]

restless/dj.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import six
22

33
from django.conf import settings
4-
from django.conf.urls import url
4+
from django.urls import path
55
from django.core.exceptions import ObjectDoesNotExist
66
from django.core.paginator import Paginator
77
from django.http import HttpResponse, Http404
@@ -128,6 +128,6 @@ def urls(cls, name_prefix=None):
128128
:returns: A list of ``url`` objects for ``include(...)``
129129
"""
130130
return [
131-
url(r'^$', cls.as_list(), name=cls.build_url_name('list', name_prefix)),
132-
url(r'^(?P<pk>[\w-]+)/$', cls.as_detail(), name=cls.build_url_name('detail', name_prefix)),
131+
path('', cls.as_list(), name=cls.build_url_name('list', name_prefix)),
132+
path('<pk>/', cls.as_detail(), name=cls.build_url_name('detail', name_prefix)),
133133
]

0 commit comments

Comments
 (0)