Skip to content

Commit 0d6589c

Browse files
brantmortoncarltongibson
authored andcommitted
Updated url() with re_path() in Versioning docs. (#7043)
1 parent 0d3d548 commit 0d6589c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

docs/api-guide/versioning.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,12 @@ This scheme requires the client to specify the version as part of the URL path.
132132
Your URL conf must include a pattern that matches the version with a `'version'` keyword argument, so that this information is available to the versioning scheme.
133133

134134
urlpatterns = [
135-
url(
135+
re_path(
136136
r'^(?P<version>(v1|v2))/bookings/$',
137137
bookings_list,
138138
name='bookings-list'
139139
),
140-
url(
140+
re_path(
141141
r'^(?P<version>(v1|v2))/bookings/(?P<pk>[0-9]+)/$',
142142
bookings_detail,
143143
name='bookings-detail'
@@ -158,14 +158,14 @@ In the following example we're giving a set of views two different possible URL
158158

159159
# bookings/urls.py
160160
urlpatterns = [
161-
url(r'^$', bookings_list, name='bookings-list'),
162-
url(r'^(?P<pk>[0-9]+)/$', bookings_detail, name='bookings-detail')
161+
re_path(r'^$', bookings_list, name='bookings-list'),
162+
re_path(r'^(?P<pk>[0-9]+)/$', bookings_detail, name='bookings-detail')
163163
]
164164

165165
# urls.py
166166
urlpatterns = [
167-
url(r'^v1/bookings/', include('bookings.urls', namespace='v1')),
168-
url(r'^v2/bookings/', include('bookings.urls', namespace='v2'))
167+
re_path(r'^v1/bookings/', include('bookings.urls', namespace='v1')),
168+
re_path(r'^v2/bookings/', include('bookings.urls', namespace='v2'))
169169
]
170170

171171
Both `URLPathVersioning` and `NamespaceVersioning` are reasonable if you just need a simple versioning scheme. The `URLPathVersioning` approach might be better suitable for small ad-hoc projects, and the `NamespaceVersioning` is probably easier to manage for larger projects.

0 commit comments

Comments
 (0)