Fix NamespaceVersioning ignoring DEFAULT_VERSION on non-None namespaces by Kostia-K · Pull Request #7278 · encode/django-rest-framework (original) (raw)
- Fix the case where if the namespace is not None and there's no match,
NamespaceVersioning always raises NotFound even if DEFAULT_VERSION
is set or None is in ALLOWED_VERSIONS - Add test cases
Description
If my namespace is just 'api'
(i.e. doesn't include version info), ALLOWED_VERSIONS
is set to ['v1', 'v2']
and DEFAULT_VERSION
is set to 'v2'
, I would expect request.version
to resolve to 'v2'
. The current behavior in this scenario is 404 Not Found
which is inconsistent with the documentation.
Similarly, if DEFAULT_VERSION
is not set and ALLOWED_VERSIONS
includes None
, I would expect request.version
to be None
. The current behavior is, once again, 404.