diff --git a/docs/api-guide/versioning.md b/docs/api-guide/versioning.md index 846698fc1..351e3bff9 100644 --- a/docs/api-guide/versioning.md +++ b/docs/api-guide/versioning.md @@ -3,7 +3,7 @@ source: versioning.py # Versioning > Versioning an interface is just a "polite" way to kill deployed clients. -> +> > — [Roy Fielding][cite]. API versioning allows you to alter behavior between different clients. REST framework provides for a number of different versioning schemes. @@ -117,12 +117,12 @@ Your URL conf must include a pattern that matches the version with a `'version'` urlpatterns = [ url( - r'^(?P{v1,v2})/bookings/$', + r'^(?P[v1|v2]+)/bookings/$', bookings_list, name='bookings-list' ), url( - r'^(?P{v1,v2})/bookings/(?P[0-9]+)/$', + r'^(?P[v1|v2]+)/bookings/(?P[0-9]+)/$', bookings_detail, name='bookings-detail' ) diff --git a/rest_framework/versioning.py b/rest_framework/versioning.py index 51b886f38..27c2d8791 100644 --- a/rest_framework/versioning.py +++ b/rest_framework/versioning.py @@ -59,8 +59,8 @@ class URLPathVersioning(BaseVersioning): An example URL conf for two views that accept two different versions. urlpatterns = [ - url(r'^(?P{v1,v2})/users/$', users_list, name='users-list'), - url(r'^(?P{v1,v2})/users/(?P[0-9]+)/$', users_detail, name='users-detail') + url(r'^(?P[v1|v2]+)/users/$', users_list, name='users-list'), + url(r'^(?P[v1|v2]+)/users/(?P[0-9]+)/$', users_detail, name='users-detail') ] GET /1.0/something/ HTTP/1.1 diff --git a/tests/test_versioning.py b/tests/test_versioning.py index 065385ad7..000762b08 100644 --- a/tests/test_versioning.py +++ b/tests/test_versioning.py @@ -128,7 +128,7 @@ class TestURLReversing(UsingURLPatterns, APITestCase): urlpatterns = [ url(r'^v1/', include(included, namespace='v1')), url(r'^another/$', dummy_view, name='another'), - url(r'^(?P[^/]+)/another/$', dummy_view, name='another'), + url(r'^(?P[v1|v2]+)/another/$', dummy_view, name='another'), ] def test_reverse_unversioned(self):