BaseVersioning
Base class for all versioning schemes.Attributes
The version to use when no versioning information is present
Set of allowed versions. If set, only these versions will be accepted
The parameter name to use for versioning. Default is
'version'Methods
determine_version(request, *args, **kwargs)
Determine the API version from the request. Must be implemented by subclasses.
The request instance
None.
reverse(viewname, args=None, kwargs=None, request=None, format=None, **extra)
Return a URL for the given view name, taking versioning into account.
is_allowed_version(version)
Return True if the version is in the allowed set.
AcceptHeaderVersioning
Versioning based on theAccept header with a media type parameter.
Request Example
Attributes
Error message for invalid versions. Default is
'Invalid version in "Accept" header.'URLPathVersioning
Versioning based on URL path keyword arguments.URL Configuration
Request Example
Attributes
Error message for invalid versions. Default is
'Invalid version in URL path.'Methods
reverse(viewname, args=None, kwargs=None, request=None, format=None, **extra)
Automatically includes the version in generated URLs.
NamespaceVersioning
Versioning based on Django URL namespaces.URL Configuration
Request Example
Attributes
Error message for invalid versions. Default is
'Invalid version in URL path. Does not match any version namespace.'Methods
get_versioned_viewname(viewname, request)
Return the versioned view name by prepending the namespace.
HostNameVersioning
Versioning based on the hostname.Request Example
Attributes
Regex pattern to extract version from hostname. Default matches
v1.example.com formatError message for invalid versions. Default is
'Invalid version in hostname.'QueryParameterVersioning
Versioning based on a query parameter.Request Example
Attributes
Error message for invalid versions. Default is
'Invalid version in query parameter.'