Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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())),
]


Expand Down
5 changes: 2 additions & 3 deletions docs/extending.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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::
Expand Down Expand Up @@ -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

8 changes: 4 additions & 4 deletions docs/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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'),
]


Expand Down
8 changes: 4 additions & 4 deletions examples/django/posts/urls.py
Original file line number Diff line number Diff line change
@@ -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'),
]
6 changes: 3 additions & 3 deletions restless/dj.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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<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)),
]
10 changes: 7 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -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 =
Expand All @@ -13,16 +13,18 @@ deps =
six
pytest
pytest-cov
WebOb>=1.3.1,<1.7
Pyramid<1.8
tornado
Pyramid<1.8
WebOb>=1.3.1,<1.7
fl10: Flask>=1.0
fl11: Flask>=1.1
fl20: Flask>=2.0
dj22: Django>=2.2,<2.3
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

Expand All @@ -40,6 +42,8 @@ DJANGO =
3.0: dj30
3.1: dj31
3.2: dj32
4.0: dj40

FLASK =
1.0: fl10
1.1: fl11
Expand Down