mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-29 13:04:03 +03:00
Merge pull request #2732 from pquentin/patch-versioning
Document per-view versioning settings
This commit is contained in:
commit
8c5fc2a94b
|
@ -74,6 +74,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`.
|
* `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'`.
|
* `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
|
# API Reference
|
||||||
|
|
Loading…
Reference in New Issue
Block a user