mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-29 04:54:00 +03:00
commit
5524339e0e
|
@ -3,7 +3,7 @@ source: versioning.py
|
||||||
# Versioning
|
# Versioning
|
||||||
|
|
||||||
> Versioning an interface is just a "polite" way to kill deployed clients.
|
> Versioning an interface is just a "polite" way to kill deployed clients.
|
||||||
>
|
>
|
||||||
> — [Roy Fielding][cite].
|
> — [Roy Fielding][cite].
|
||||||
|
|
||||||
API versioning allows you to alter behavior between different clients. REST framework provides for a number of different versioning schemes.
|
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 = [
|
urlpatterns = [
|
||||||
url(
|
url(
|
||||||
r'^(?P<version>{v1,v2})/bookings/$',
|
r'^(?P<version>[v1|v2]+)/bookings/$',
|
||||||
bookings_list,
|
bookings_list,
|
||||||
name='bookings-list'
|
name='bookings-list'
|
||||||
),
|
),
|
||||||
url(
|
url(
|
||||||
r'^(?P<version>{v1,v2})/bookings/(?P<pk>[0-9]+)/$',
|
r'^(?P<version>[v1|v2]+)/bookings/(?P<pk>[0-9]+)/$',
|
||||||
bookings_detail,
|
bookings_detail,
|
||||||
name='bookings-detail'
|
name='bookings-detail'
|
||||||
)
|
)
|
||||||
|
|
|
@ -59,8 +59,8 @@ class URLPathVersioning(BaseVersioning):
|
||||||
An example URL conf for two views that accept two different versions.
|
An example URL conf for two views that accept two different versions.
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^(?P<version>{v1,v2})/users/$', users_list, name='users-list'),
|
url(r'^(?P<version>[v1|v2]+)/users/$', users_list, name='users-list'),
|
||||||
url(r'^(?P<version>{v1,v2})/users/(?P<pk>[0-9]+)/$', users_detail, name='users-detail')
|
url(r'^(?P<version>[v1|v2]+)/users/(?P<pk>[0-9]+)/$', users_detail, name='users-detail')
|
||||||
]
|
]
|
||||||
|
|
||||||
GET /1.0/something/ HTTP/1.1
|
GET /1.0/something/ HTTP/1.1
|
||||||
|
|
|
@ -128,7 +128,7 @@ class TestURLReversing(UsingURLPatterns, APITestCase):
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^v1/', include(included, namespace='v1')),
|
url(r'^v1/', include(included, namespace='v1')),
|
||||||
url(r'^another/$', dummy_view, name='another'),
|
url(r'^another/$', dummy_view, name='another'),
|
||||||
url(r'^(?P<version>[^/]+)/another/$', dummy_view, name='another'),
|
url(r'^(?P<version>[v1|v2]+)/another/$', dummy_view, name='another'),
|
||||||
]
|
]
|
||||||
|
|
||||||
def test_reverse_unversioned(self):
|
def test_reverse_unversioned(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user