From 8ba66e2c10803fa53a6c2b3d1bae19311bb797f3 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Fri, 20 Mar 2015 15:06:30 +0100 Subject: [PATCH] Document per-view versioning settings That is, document the default_version, allowed_version and version_param class variables. --- docs/api-guide/versioning.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/api-guide/versioning.md b/docs/api-guide/versioning.md index a227a4a3d..795b46ca1 100644 --- a/docs/api-guide/versioning.md +++ b/docs/api-guide/versioning.md @@ -72,6 +72,19 @@ The following settings keys are also used to control versioning: * `ALLOWED_VERSIONS`. If set, this value will restrict the set of versions that may be returned by the versioning scheme, and will raise an error if the provided version if not in this set. Defaults to `None`. * `VERSION_PARAMETER`. The string that should used for any versioning parameters, such as in the media type or URL query parameters. Defaults to `'version'`. +You can also set your versioning class plus those three values on a per-view or a per-viewset basis by defining your own versioning scheme and using the `default_version`, `allowed_versions` and `version_param` class variables. For example, if you want to use `URLPathVersioning`: + + from rest_framework.versioning import URLPathVersioning + from rest_framework.views import APIView + + class ExampleVersioning(URLPathVersioning): + default_version = ... + allowed_versions = ... + version_param = ... + + class ExampleView(APIVIew): + versioning_class = ExampleVersioning + --- # API Reference