Skip to content

Commit b37cec0

Browse files
slivercn2ygk
andauthored
Updated urls to use path and re_path as is default in Django 2.2. (#1027)
django.urls.conf.url is only there for Python 3.5 support which we already deleted anyway. Co-authored-by: Alan Crosswell <alan@columbia.edu>
1 parent a9ac156 commit b37cec0

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

example/urls.py

+13-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from django.conf import settings
2-
from django.conf.urls import include, url
3-
from django.urls import path
2+
from django.urls import include, path, re_path
43
from django.views.generic import TemplateView
54
from rest_framework import routers
65
from rest_framework.schemas import get_schema_view
@@ -36,53 +35,53 @@
3635
router.register(r"lab-results", LabResultViewSet)
3736

3837
urlpatterns = [
39-
url(r"^", include(router.urls)),
40-
url(
38+
path("", include(router.urls)),
39+
re_path(
4140
r"^entries/(?P<entry_pk>[^/.]+)/suggested/$",
4241
EntryViewSet.as_view({"get": "list"}),
4342
name="entry-suggested",
4443
),
45-
url(
44+
re_path(
4645
r"entries/(?P<entry_pk>[^/.]+)/blog$",
4746
BlogViewSet.as_view({"get": "retrieve"}),
4847
name="entry-blog",
4948
),
50-
url(
49+
re_path(
5150
r"entries/(?P<entry_pk>[^/.]+)/comments$",
5251
CommentViewSet.as_view({"get": "list"}),
5352
name="entry-comments",
5453
),
55-
url(
54+
re_path(
5655
r"entries/(?P<entry_pk>[^/.]+)/authors$",
5756
AuthorViewSet.as_view({"get": "list"}),
5857
name="entry-authors",
5958
),
60-
url(
59+
re_path(
6160
r"entries/(?P<entry_pk>[^/.]+)/featured$",
6261
EntryViewSet.as_view({"get": "retrieve"}),
6362
name="entry-featured",
6463
),
65-
url(
64+
re_path(
6665
r"^authors/(?P<pk>[^/.]+)/(?P<related_field>\w+)/$",
6766
AuthorViewSet.as_view({"get": "retrieve_related"}),
6867
name="author-related",
6968
),
70-
url(
69+
re_path(
7170
r"^entries/(?P<pk>[^/.]+)/relationships/(?P<related_field>\w+)$",
7271
EntryRelationshipView.as_view(),
7372
name="entry-relationships",
7473
),
75-
url(
74+
re_path(
7675
r"^blogs/(?P<pk>[^/.]+)/relationships/(?P<related_field>\w+)$",
7776
BlogRelationshipView.as_view(),
7877
name="blog-relationships",
7978
),
80-
url(
79+
re_path(
8180
r"^comments/(?P<pk>[^/.]+)/relationships/(?P<related_field>\w+)$",
8281
CommentRelationshipView.as_view(),
8382
name="comment-relationships",
8483
),
85-
url(
84+
re_path(
8685
r"^authors/(?P<pk>[^/.]+)/relationships/(?P<related_field>\w+)$",
8786
AuthorRelationshipView.as_view(),
8887
name="author-relationships",
@@ -111,5 +110,5 @@
111110
import debug_toolbar
112111

113112
urlpatterns = [
114-
url(r"^__debug__/", include(debug_toolbar.urls)),
113+
path("__debug__/", include(debug_toolbar.urls)),
115114
] + urlpatterns

0 commit comments

Comments
 (0)