1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
|
From: r-lelis <lelis@labcodes.com.br>
Date: Sun, 15 Aug 2021 11:38:16 -0300
Subject: [PATCH] use path function instead of url function
Origin: upstream, https://github.com/toastdriven/restless/pull/129/commits/d1410857ae93ba3f3b8173c5f8a292584f3d1a95
Bug-Debian: https://bugs.debian.org/1013477
---
README.rst | 4 ++--
docs/extending.rst | 5 ++---
docs/tutorial.rst | 8 ++++----
examples/django/posts/urls.py | 8 ++++----
restless/dj.py | 6 +++---
5 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/README.rst b/README.rst
index 777b855..9a9de04 100644
--- a/README.rst
+++ b/README.rst
@@ -134,14 +134,14 @@ Hooking it up:
.. code:: python
# api/urls.py
- from django.conf.urls.default import url, include
+ from django.urls import include, path
from posts.api import PostResource
urlpatterns = [
# The usual suspects, then...
- url(r'^api/posts/', include(PostResource.urls())),
+ path('api/posts/', include(PostResource.urls())),
]
diff --git a/docs/extending.rst b/docs/extending.rst
index 8dcea20..e425a95 100644
--- a/docs/extending.rst
+++ b/docs/extending.rst
@@ -92,7 +92,7 @@ Finally, it's just a matter of hooking up the URLs as well. You can do this
manually or (once again) by extending a built-in method.::
# Add the correct import here.
- from django.conf.urls import url
+ from django.urls import path
from restless.dj import DjangoResource
from restless.resources import skip_prepare
@@ -129,7 +129,7 @@ manually or (once again) by extending a built-in method.::
def urls(cls, name_prefix=None):
urlpatterns = super(PostResource, cls).urls(name_prefix=name_prefix)
return [
- url(r'^schema/$', cls.as_view('schema'), name=cls.build_url_name('schema', name_prefix)),
+ path('schema/', cls.as_view('schema'), name=cls.build_url_name('schema', name_prefix)),
] + urlpatterns
.. note::
@@ -575,4 +575,3 @@ user provides a ``?format=yaml`` GET param...::
return json.dumps(body, cls=MoreTypesJSONEncoder)
.. _`a host of problems`: https://pypi.python.org/pypi/defusedxml
-
diff --git a/docs/tutorial.rst b/docs/tutorial.rst
index da32052..e749bee 100644
--- a/docs/tutorial.rst
+++ b/docs/tutorial.rst
@@ -260,7 +260,7 @@ practice would be to create a URLconf just for the API portion of your site.::
# The ``settings.ROOT_URLCONF`` file
# myproject/urls.py
- from django.conf.urls import url, include
+ from django.urls import path, include
# Add this!
from posts.api import PostResource
@@ -269,7 +269,7 @@ practice would be to create a URLconf just for the API portion of your site.::
# The usual fare, then...
# Add this!
- url(r'api/posts/', include(PostResource.urls())),
+ path('api/posts/', include(PostResource.urls())),
]
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::
# ...
# Identical to the above.
- url(r'api/posts/$', PostResource.as_list(), name='api_post_list'),
- url(r'api/posts/(?P<pk>\d+)/$', PostResource.as_detail(), name='api_post_detail'),
+ path('api/posts/', PostResource.as_list(), name='api_post_list'),
+ path('api/posts/<pk>/', PostResource.as_detail(), name='api_post_detail'),
]
diff --git a/examples/django/posts/urls.py b/examples/django/posts/urls.py
index 4d235aa..2f6a203 100644
--- a/examples/django/posts/urls.py
+++ b/examples/django/posts/urls.py
@@ -1,12 +1,12 @@
-from django.conf.urls import url, include
+from django.urls import path, include
from .api import PostResource
urlpatterns = [
- url(r'^posts/', include(PostResource.urls())),
+ path('posts/', include(PostResource.urls())),
# Alternatively, if you don't like the defaults...
- # url(r'^posts/$', PostResource.as_list(), name='api_posts_list'),
- # url(r'^posts/(?P<pk>\d+)/$', PostResource.as_detail(), name='api_posts_detail'),
+ # path('posts/', PostResource.as_list(), name='api_posts_list'),
+ # path('posts/<pk>/', PostResource.as_detail(), name='api_posts_detail'),
]
diff --git a/restless/dj.py b/restless/dj.py
index 2d7a0fc..886e603 100644
--- a/restless/dj.py
+++ b/restless/dj.py
@@ -1,7 +1,7 @@
import six
from django.conf import settings
-from django.conf.urls import url
+from django.urls import path
from django.core.exceptions import ObjectDoesNotExist
from django.core.paginator import Paginator
from django.http import HttpResponse, Http404
@@ -128,6 +128,6 @@ class DjangoResource(Resource):
:returns: A list of ``url`` objects for ``include(...)``
"""
return [
- url(r'^$', cls.as_list(), name=cls.build_url_name('list', name_prefix)),
- url(r'^(?P<pk>[\w-]+)/$', cls.as_detail(), name=cls.build_url_name('detail', name_prefix)),
+ path('', cls.as_list(), name=cls.build_url_name('list', name_prefix)),
+ path('<pk>/', cls.as_detail(), name=cls.build_url_name('detail', name_prefix)),
]
|