From d1410857ae93ba3f3b8173c5f8a292584f3d1a95 Mon Sep 17 00:00:00 2001 From: r-lelis Date: Sun, 15 Aug 2021 11:38:16 -0300 Subject: [PATCH 1/4] use path funcion instead of url funcion --- 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 e6d4c75..1a56c24 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().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 77bd56c..82941bb 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\d+)/$', PostResource.as_detail(), name='api_post_detail'), + path('api/posts/', PostResource.as_list(), name='api_post_list'), + path('api/posts//', 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\d+)/$', PostResource.as_detail(), name='api_posts_detail'), + # path('posts/', PostResource.as_list(), name='api_posts_list'), + # path('posts//', 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 @@ def urls(cls, name_prefix=None): :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[\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('/', cls.as_detail(), name=cls.build_url_name('detail', name_prefix)), ] From 32aa8493fdaf1b9a001d13176eb64956eb3fbf13 Mon Sep 17 00:00:00 2001 From: r-lelis Date: Mon, 20 Dec 2021 16:55:21 -0300 Subject: [PATCH 2/4] Add Django 4.0 support on tox --- tox.ini | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index ac05a3f..37b358d 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] envlist = - py{36,37,38,39,py}-{dj22,dj30,dj31,dj32}-{fl10,fl11,fl20} + py{36,37,38,39,py}-{dj22,dj30,dj31,dj32}-{fl10,fl11,fl20},py{38,39,py}-{dj40} [testenv] basepython = @@ -13,9 +13,9 @@ deps = six pytest pytest-cov + tornado WebOb>=1.3.1,<1.7 Pyramid<1.8 - tornado fl10: Flask>=1.0 fl11: Flask>=1.1 fl20: Flask>=2.0 @@ -23,6 +23,8 @@ deps = dj30: Django>=3.0,<3.1 dj31: Django>=3.1,<3.2 dj32: Django>=3.2,<3.3 + dj40: Django>=4.0,<4.1 + commands = pytest --cov=restless @@ -40,6 +42,8 @@ DJANGO = 3.0: dj30 3.1: dj31 3.2: dj32 + 4.0: dj40 + FLASK = 1.0: fl10 1.1: fl11 From a2e5b0c8ca1f25981c6bf893a86c61dbe4fdc797 Mon Sep 17 00:00:00 2001 From: r-lelis Date: Tue, 21 Dec 2021 10:37:53 -0300 Subject: [PATCH 3/4] Add Django 4.0 to travis CI --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index c5c3405..22f7759 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ env: - DJANGO="3.0" - DJANGO="3.1" - DJANGO="3.2" + - DJANGO="4.0" - FLASK="1.0" - FLASK="1.1" - FLASK="2.0" From 9caf4c30ea8cf6e22813a59bb33884710fc464da Mon Sep 17 00:00:00 2001 From: r-lelis Date: Thu, 23 Dec 2021 10:39:12 -0300 Subject: [PATCH 4/4] Rearrange deps list on tox.ini --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 37b358d..3a097e2 100644 --- a/tox.ini +++ b/tox.ini @@ -14,8 +14,8 @@ deps = pytest pytest-cov tornado - WebOb>=1.3.1,<1.7 Pyramid<1.8 + WebOb>=1.3.1,<1.7 fl10: Flask>=1.0 fl11: Flask>=1.1 fl20: Flask>=2.0