django-api-versioning 1.0.0__tar.gz → 1.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/CHANGELOG.md +16 -1
  2. django_api_versioning-1.0.1/PKG-INFO +223 -0
  3. django_api_versioning-1.0.1/README.md +173 -0
  4. django_api_versioning-1.0.1/django_api_versioning.egg-info/PKG-INFO +223 -0
  5. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/pyproject.toml +11 -15
  6. django_api_versioning-1.0.0/PKG-INFO +0 -1116
  7. django_api_versioning-1.0.0/README.md +0 -1068
  8. django_api_versioning-1.0.0/django_api_versioning.egg-info/PKG-INFO +0 -1116
  9. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/LICENSE +0 -0
  10. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/MANIFEST.in +0 -0
  11. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/django_api_versioning/__init__.py +0 -0
  12. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/django_api_versioning/channels.py +0 -0
  13. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/django_api_versioning/decorators.py +0 -0
  14. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/django_api_versioning/exceptions.py +0 -0
  15. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/django_api_versioning/lifecycle.py +0 -0
  16. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/django_api_versioning/management/__init__.py +0 -0
  17. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/django_api_versioning/management/commands/__init__.py +0 -0
  18. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/django_api_versioning/management/commands/check_versions.py +0 -0
  19. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/django_api_versioning/management/commands/migrate_endpoints.py +0 -0
  20. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/django_api_versioning/py.typed +0 -0
  21. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/django_api_versioning/registry.py +0 -0
  22. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/django_api_versioning/reverse.py +0 -0
  23. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/django_api_versioning/settings.py +0 -0
  24. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/django_api_versioning/testing.py +0 -0
  25. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/django_api_versioning/urls.py +0 -0
  26. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/django_api_versioning.egg-info/SOURCES.txt +0 -0
  27. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/django_api_versioning.egg-info/dependency_links.txt +0 -0
  28. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/django_api_versioning.egg-info/requires.txt +0 -0
  29. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/django_api_versioning.egg-info/top_level.txt +0 -0
  30. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/pytest.ini +0 -0
  31. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/requirements-dev.txt +0 -0
  32. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/requirements.txt +0 -0
  33. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/setup.cfg +0 -0
  34. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/tests/__init__.py +0 -0
  35. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/tests/conftest.py +0 -0
  36. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/tests/settings.py +0 -0
  37. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/tests/test_channels.py +0 -0
  38. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/tests/test_channels_extra.py +0 -0
  39. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/tests/test_decorators.py +0 -0
  40. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/tests/test_distribution_contents.py +0 -0
  41. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/tests/test_exceptions.py +0 -0
  42. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/tests/test_lifecycle.py +0 -0
  43. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/tests/test_management_commands.py +0 -0
  44. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/tests/test_registry.py +0 -0
  45. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/tests/test_reverse.py +0 -0
  46. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/tests/test_segment_model.py +0 -0
  47. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/tests/test_settings.py +0 -0
  48. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/tests/test_testing_utils.py +0 -0
  49. {django_api_versioning-1.0.0 → django_api_versioning-1.0.1}/tests/test_urls.py +0 -0
@@ -8,6 +8,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8
8
 
9
9
  ## [Unreleased]
10
10
 
11
+ ## [1.0.1] - 2026-11-17
12
+
13
+ ### Documentation
14
+
15
+ - Rework the README onboarding flow to show a working DRF example and generated version routes before the detailed explanation.
16
+ - Add descriptive links to the official documentation site and PyPI, plus the website logo and current PyPI version badge.
17
+ - Use absolute repository links in the README so the PyPI long description retains working source links.
18
+ - Expand and reconcile the canonical API reference, routing contract, article index, and documentation ownership guidance.
19
+ - Correct lifecycle documentation and examples to match the released 1.0.0 behavior.
20
+ - Add and refine Homepage, Documentation, Source, Issues, Changelog, and Security project URLs in package metadata.
21
+
22
+ ### Packaging
23
+
24
+ - Publish updated project metadata and documentation only; no runtime code or dependency changes.
25
+
11
26
  ## [1.0.0] - 2026-11-16
12
27
 
13
28
  ### Added
@@ -160,7 +175,7 @@ The package runtime minimum remains Python 3.10 and Django 4.2. Django REST Fram
160
175
  - **Comprehensive Integration Testing:** 222+ integration tests covering DRF APIView, GenericAPIView, ViewSets, routers, custom actions, authentication, permissions, and Django-native views.
161
176
  - **Enhanced Testing Infrastructure:** Management command tests for `check_versions` and version matrix validation.
162
177
  - **Feature Verification Matrix:** Complete traceability matrix documenting 90+ features verified against implementation.
163
- - **Compatibility Report:** Comprehensive Python 3.10+, Django 4.2–6.1, and DRF 3.14+ compatibility matrix with test results.
178
+ - **Historical compatibility report:** [v0.3.8 compatibility evidence](docs/reports/compatibility-0.3.8.md), covering the Python 3.10+, Django 4.2–6.1, and DRF 3.14+ matrix at that release.
164
179
 
165
180
  ### Changed
166
181
 
@@ -0,0 +1,223 @@
1
+ Metadata-Version: 2.4
2
+ Name: django-api-versioning
3
+ Version: 1.0.1
4
+ Summary: URL-path API versioning for Django and Django REST Framework with decorator-based endpoint registration and forward route inheritance.
5
+ Author-email: Mojtaba Arvin <ArvinDevDay@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://mojtaba-arvin.github.io/django-api-versioning/
8
+ Project-URL: Documentation, https://mojtaba-arvin.github.io/django-api-versioning/reference/
9
+ Project-URL: Source, https://github.com/mojtaba-arvin/django-api-versioning
10
+ Project-URL: Issues, https://github.com/mojtaba-arvin/django-api-versioning/issues
11
+ Project-URL: Changelog, https://github.com/mojtaba-arvin/django-api-versioning/blob/main/CHANGELOG.md
12
+ Project-URL: Security, https://github.com/mojtaba-arvin/django-api-versioning/blob/main/SECURITY.md
13
+ Keywords: django api versioning,django rest framework api versioning,drf versioning,url path api versioning,versioned url routing,endpoint registration,version-specific django views,django-api-versioning
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Programming Language :: Python :: 3.15
21
+ Classifier: Framework :: Django
22
+ Classifier: Framework :: Django :: 4.2
23
+ Classifier: Framework :: Django :: 5.2
24
+ Classifier: Framework :: Django :: 6.0
25
+ Classifier: Framework :: Django :: 6.1
26
+ Classifier: Development Status :: 5 - Production/Stable
27
+ Classifier: Intended Audience :: Developers
28
+ Classifier: Operating System :: OS Independent
29
+ Classifier: Topic :: Internet :: WWW/HTTP
30
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
31
+ Classifier: Typing :: Typed
32
+ Requires-Python: >=3.10
33
+ Description-Content-Type: text/markdown
34
+ License-File: LICENSE
35
+ Requires-Dist: Django>=4.2
36
+ Provides-Extra: dev
37
+ Requires-Dist: black>=26.10.1; extra == "dev"
38
+ Requires-Dist: flake8>=7.4.1; extra == "dev"
39
+ Requires-Dist: isort>=9.0.2; extra == "dev"
40
+ Requires-Dist: mypy>=2.4.0; extra == "dev"
41
+ Requires-Dist: pytest>=9.2.0; extra == "dev"
42
+ Requires-Dist: pytest-django>=4.14.0; extra == "dev"
43
+ Requires-Dist: pytest-cov>=7.1.0; extra == "dev"
44
+ Requires-Dist: pre-commit>=4.7.0; python_version >= "3.11" and extra == "dev"
45
+ Requires-Dist: twine>=7.0.0; extra == "dev"
46
+ Requires-Dist: build>=1.6.1; extra == "dev"
47
+ Requires-Dist: djangorestframework>=3.18; extra == "dev"
48
+ Requires-Dist: tomli>=2.0.1; python_version < "3.11" and extra == "dev"
49
+ Dynamic: license-file
50
+
51
+ <p align="center">
52
+ <a href="https://mojtaba-arvin.github.io/django-api-versioning/">
53
+ <img src="https://raw.githubusercontent.com/mojtaba-arvin/django-api-versioning/main/website/public/favicon.svg" alt="Django API Versioning logo" width="64" height="64">
54
+ </a>
55
+ </p>
56
+
57
+ # Django API Versioning
58
+
59
+ [![PyPI version](https://img.shields.io/pypi/v/django-api-versioning?logo=pypi&logoColor=white)](https://pypi.org/project/django-api-versioning/)
60
+ [![Python versions](https://img.shields.io/pypi/pyversions/django-api-versioning.svg)](https://pypi.org/project/django-api-versioning/)
61
+ [![Django versions](https://img.shields.io/badge/django-4.2%20%7C%205.2%20%7C%206.0%20%7C%206.1-blue)](https://github.com/mojtaba-arvin/django-api-versioning/blob/main/tox.ini)
62
+ [![Python tests](https://github.com/mojtaba-arvin/django-api-versioning/actions/workflows/tests.yml/badge.svg)](https://github.com/mojtaba-arvin/django-api-versioning/actions/workflows/tests.yml)
63
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/mojtaba-arvin/django-api-versioning/blob/main/LICENSE)
64
+
65
+ **Version your Django API by endpoint, not by duplicating URL patterns.** Register a view once; unchanged routes carry forward to later API versions, and a newer declaration replaces the implementation from that version onward.
66
+
67
+ [Explore Django API Versioning — documentation, examples, and interactive playground](https://mojtaba-arvin.github.io/django-api-versioning/) · [Install django-api-versioning from PyPI](https://pypi.org/project/django-api-versioning/)
68
+
69
+ ## See how it works
70
+
71
+ Install the package and Django REST Framework:
72
+
73
+ ```bash
74
+ pip install django-api-versioning djangorestframework
75
+ ```
76
+
77
+ Declare only the versions where an endpoint's behavior changes:
78
+
79
+ ```python
80
+ from rest_framework.response import Response
81
+ from rest_framework.views import APIView
82
+
83
+ from django_api_versioning import endpoint
84
+
85
+
86
+ @endpoint("orders/", version=1, view_name="order-list")
87
+ class OrderListV1(APIView):
88
+ def get(self, request):
89
+ return Response({"total": "19.99"})
90
+
91
+
92
+ @endpoint("orders/", version=2, view_name="order-list")
93
+ class OrderListV2(APIView):
94
+ def get(self, request):
95
+ return Response({"total": 1999, "currency": "USD"})
96
+ ```
97
+
98
+ With `API_MAX_VERSION = 3`, the generated routes are:
99
+
100
+ | Request | View |
101
+ | --- | --- |
102
+ | `GET /api/v1/orders/` | `OrderListV1` |
103
+ | `GET /api/v2/orders/` | `OrderListV2` |
104
+ | `GET /api/v3/orders/` | `OrderListV2` |
105
+
106
+ The v1 view serves v1 until another declaration replaces it. The v2 view then serves v2 and v3. **You write a new view when the endpoint changes—not another copy of every unchanged route.**
107
+
108
+ For the complete setup, including Django settings and URL configuration, see the [Django API Versioning getting-started guide](https://mojtaba-arvin.github.io/django-api-versioning/articles/022-django-api-versioning-how-does-it-work/).
109
+
110
+ ## What problem does it solve?
111
+
112
+ In a growing API, only some endpoints change between releases. Manually maintaining a separate URL configuration for every version can repeat registrations and obscure which implementation handles each version.
113
+
114
+ Django API Versioning makes that mapping explicit with `@endpoint`:
115
+
116
+ - **Forward route inheritance:** `version=1` registers the endpoint from v1 through `API_MAX_VERSION`.
117
+ - **Version-specific replacement:** a v2 declaration takes over from v2 onward; earlier versions retain the v1 implementation.
118
+ - **Explicit registration:** use `versions=[...]` or `ver_range(...)` when an endpoint should exist only in selected versions.
119
+ - **Visibility:** inspect the generated route matrix with `check_versions` and test it with `assert_version_matrix()`.
120
+
121
+ This is inheritance of route registrations, not automatic backward compatibility. Your application remains responsible for response schemas, business behavior, and compatibility tests.
122
+
123
+ ## Why use it with Django REST Framework?
124
+
125
+ DRF already provides versioning schemes to identify the requested API version, for example through `request.version`. This package solves a related but different problem: **mapping versioned URL paths to specific view implementations and carrying unchanged registrations forward**.
126
+
127
+ Use DRF's built-in versioning when request-version identification is all you need. Use this package when you want declarative version-to-view routing and an inspectable route matrix. They can be used together; this package does not automatically populate `request.version`.
128
+
129
+ DRF is optional. The package also supports Django function-based and class-based views. For a Django-only project, install just:
130
+
131
+ ```bash
132
+ pip install django-api-versioning
133
+ ```
134
+
135
+ ## Quick configuration
136
+
137
+ Add the package (and DRF, if used) to `INSTALLED_APPS` and configure the supported version range:
138
+
139
+ ```python
140
+ # settings.py
141
+ INSTALLED_APPS = [
142
+ "rest_framework", # omit when using Django-native views only
143
+ "django_api_versioning",
144
+ ]
145
+
146
+ API_MIN_VERSION = 1
147
+ API_MAX_VERSION = 3
148
+ # API_BASE_PATH defaults to "api/v{version}/"
149
+ ```
150
+
151
+ Import modules containing endpoint declarations before including the generated patterns:
152
+
153
+ ```python
154
+ # project/urls.py
155
+ from django.urls import include, path
156
+
157
+ from orders import views as _order_views # noqa: F401
158
+ from django_api_versioning.urls import urlpatterns as api_urlpatterns
159
+
160
+ urlpatterns = [
161
+ path("", include(api_urlpatterns)),
162
+ ]
163
+ ```
164
+
165
+ Run the route-matrix check:
166
+
167
+ ```bash
168
+ python manage.py check_versions
169
+ ```
170
+
171
+ ## Registration options
172
+
173
+ | Declaration | Routes created |
174
+ | --- | --- |
175
+ | `@endpoint("orders/", version=2)` | v2 through `API_MAX_VERSION` |
176
+ | `@endpoint("orders/", versions=[1, 3, 5])` | Only v1, v3, and v5 |
177
+ | `@endpoint("health/")` | One unversioned route |
178
+
179
+ For an inclusive range, use `ver_range(1, 3)`. Other APIs include `api_reverse()` for version-aware URL reversal and `assert_version_matrix()` for regression tests.
180
+
181
+ See the [versioning contract](https://github.com/mojtaba-arvin/django-api-versioning/blob/main/docs/reference/versioning-contract.md) for exact URL construction, import order, collision precedence, validation, and edge cases.
182
+
183
+ ## DRF ViewSet boundary
184
+
185
+ A DRF `ViewSet` or `ModelViewSet` cannot be passed directly to `@endpoint`, because `as_view()` requires an action mapping. You can register a configured callable for an individual route, but this does not create the full router-managed set of list, detail, and custom-action routes. Use DRF's `DefaultRouter` or `SimpleRouter` when you need standard ViewSet routing.
186
+
187
+ See [ViewSet support and limitations](https://mojtaba-arvin.github.io/django-api-versioning/articles/025-django-api-versioning-viewset-support-limitations/).
188
+
189
+ ## Requirements
190
+
191
+ - Python 3.10+
192
+ - Django 4.2+
193
+ - Django REST Framework is optional.
194
+
195
+ The configured CI matrix covers selected combinations of Python 3.10–3.15 and Django 4.2, 5.2, 6.0, and 6.1. See [tox.ini](https://github.com/mojtaba-arvin/django-api-versioning/blob/main/tox.ini) for configured environments and [GitHub Actions](https://github.com/mojtaba-arvin/django-api-versioning/actions) for results tied to a specific commit.
196
+
197
+ ## Upgrading to 1.0.0
198
+
199
+ Version 1.0.0 tightened API lifecycle configuration and changed the `Deprecation` response header format. If you use `API_VERSION_LIFECYCLE`:
200
+
201
+ - Every entry must have a `status` of `active`, `deprecated`, or `retired`.
202
+ - A deprecated version must define `deprecated_at` as an ISO 8601 date or datetime.
203
+ - A retired version must define a `sunset` date.
204
+ - The `Deprecation` header now uses the RFC 9745 date-valued Structured Field (for example, `Deprecation: @1767225600`), not the legacy `Deprecation: true` value.
205
+
206
+ For migration steps, see the [1.0.0 changelog](https://github.com/mojtaba-arvin/django-api-versioning/blob/main/CHANGELOG.md#100---2026-11-16).
207
+
208
+ ## Documentation
209
+
210
+ - [Django API Versioning documentation and interactive playground](https://mojtaba-arvin.github.io/django-api-versioning/) — overview, examples, lifecycle demonstration, and guides.
211
+ - [API reference](https://mojtaba-arvin.github.io/django-api-versioning/reference/) — settings, decorators, URL reversal, validation, and management commands.
212
+ - [Routing contract](https://github.com/mojtaba-arvin/django-api-versioning/blob/main/docs/reference/versioning-contract.md) — implementation-backed behavior and limitations.
213
+ - [DRF integration guide](https://mojtaba-arvin.github.io/django-api-versioning/articles/013-drf-version-negotiation-vs-endpoint-registration/).
214
+ - [Python and Django compatibility guide](https://mojtaba-arvin.github.io/django-api-versioning/articles/024-django-api-versioning-supported-django-python-versions/).
215
+ - [Documentation source map](https://github.com/mojtaba-arvin/django-api-versioning/blob/main/docs/README.md).
216
+
217
+ ## Contributing
218
+
219
+ Bug reports, corrections, and pull requests are welcome. Read the [contribution guidelines](https://github.com/mojtaba-arvin/django-api-versioning/blob/main/CONTRIBUTING.md) and [security policy](https://github.com/mojtaba-arvin/django-api-versioning/blob/main/SECURITY.md).
220
+
221
+ ## License
222
+
223
+ Released under the [MIT License](https://github.com/mojtaba-arvin/django-api-versioning/blob/main/LICENSE).
@@ -0,0 +1,173 @@
1
+ <p align="center">
2
+ <a href="https://mojtaba-arvin.github.io/django-api-versioning/">
3
+ <img src="https://raw.githubusercontent.com/mojtaba-arvin/django-api-versioning/main/website/public/favicon.svg" alt="Django API Versioning logo" width="64" height="64">
4
+ </a>
5
+ </p>
6
+
7
+ # Django API Versioning
8
+
9
+ [![PyPI version](https://img.shields.io/pypi/v/django-api-versioning?logo=pypi&logoColor=white)](https://pypi.org/project/django-api-versioning/)
10
+ [![Python versions](https://img.shields.io/pypi/pyversions/django-api-versioning.svg)](https://pypi.org/project/django-api-versioning/)
11
+ [![Django versions](https://img.shields.io/badge/django-4.2%20%7C%205.2%20%7C%206.0%20%7C%206.1-blue)](https://github.com/mojtaba-arvin/django-api-versioning/blob/main/tox.ini)
12
+ [![Python tests](https://github.com/mojtaba-arvin/django-api-versioning/actions/workflows/tests.yml/badge.svg)](https://github.com/mojtaba-arvin/django-api-versioning/actions/workflows/tests.yml)
13
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/mojtaba-arvin/django-api-versioning/blob/main/LICENSE)
14
+
15
+ **Version your Django API by endpoint, not by duplicating URL patterns.** Register a view once; unchanged routes carry forward to later API versions, and a newer declaration replaces the implementation from that version onward.
16
+
17
+ [Explore Django API Versioning — documentation, examples, and interactive playground](https://mojtaba-arvin.github.io/django-api-versioning/) · [Install django-api-versioning from PyPI](https://pypi.org/project/django-api-versioning/)
18
+
19
+ ## See how it works
20
+
21
+ Install the package and Django REST Framework:
22
+
23
+ ```bash
24
+ pip install django-api-versioning djangorestframework
25
+ ```
26
+
27
+ Declare only the versions where an endpoint's behavior changes:
28
+
29
+ ```python
30
+ from rest_framework.response import Response
31
+ from rest_framework.views import APIView
32
+
33
+ from django_api_versioning import endpoint
34
+
35
+
36
+ @endpoint("orders/", version=1, view_name="order-list")
37
+ class OrderListV1(APIView):
38
+ def get(self, request):
39
+ return Response({"total": "19.99"})
40
+
41
+
42
+ @endpoint("orders/", version=2, view_name="order-list")
43
+ class OrderListV2(APIView):
44
+ def get(self, request):
45
+ return Response({"total": 1999, "currency": "USD"})
46
+ ```
47
+
48
+ With `API_MAX_VERSION = 3`, the generated routes are:
49
+
50
+ | Request | View |
51
+ | --- | --- |
52
+ | `GET /api/v1/orders/` | `OrderListV1` |
53
+ | `GET /api/v2/orders/` | `OrderListV2` |
54
+ | `GET /api/v3/orders/` | `OrderListV2` |
55
+
56
+ The v1 view serves v1 until another declaration replaces it. The v2 view then serves v2 and v3. **You write a new view when the endpoint changes—not another copy of every unchanged route.**
57
+
58
+ For the complete setup, including Django settings and URL configuration, see the [Django API Versioning getting-started guide](https://mojtaba-arvin.github.io/django-api-versioning/articles/022-django-api-versioning-how-does-it-work/).
59
+
60
+ ## What problem does it solve?
61
+
62
+ In a growing API, only some endpoints change between releases. Manually maintaining a separate URL configuration for every version can repeat registrations and obscure which implementation handles each version.
63
+
64
+ Django API Versioning makes that mapping explicit with `@endpoint`:
65
+
66
+ - **Forward route inheritance:** `version=1` registers the endpoint from v1 through `API_MAX_VERSION`.
67
+ - **Version-specific replacement:** a v2 declaration takes over from v2 onward; earlier versions retain the v1 implementation.
68
+ - **Explicit registration:** use `versions=[...]` or `ver_range(...)` when an endpoint should exist only in selected versions.
69
+ - **Visibility:** inspect the generated route matrix with `check_versions` and test it with `assert_version_matrix()`.
70
+
71
+ This is inheritance of route registrations, not automatic backward compatibility. Your application remains responsible for response schemas, business behavior, and compatibility tests.
72
+
73
+ ## Why use it with Django REST Framework?
74
+
75
+ DRF already provides versioning schemes to identify the requested API version, for example through `request.version`. This package solves a related but different problem: **mapping versioned URL paths to specific view implementations and carrying unchanged registrations forward**.
76
+
77
+ Use DRF's built-in versioning when request-version identification is all you need. Use this package when you want declarative version-to-view routing and an inspectable route matrix. They can be used together; this package does not automatically populate `request.version`.
78
+
79
+ DRF is optional. The package also supports Django function-based and class-based views. For a Django-only project, install just:
80
+
81
+ ```bash
82
+ pip install django-api-versioning
83
+ ```
84
+
85
+ ## Quick configuration
86
+
87
+ Add the package (and DRF, if used) to `INSTALLED_APPS` and configure the supported version range:
88
+
89
+ ```python
90
+ # settings.py
91
+ INSTALLED_APPS = [
92
+ "rest_framework", # omit when using Django-native views only
93
+ "django_api_versioning",
94
+ ]
95
+
96
+ API_MIN_VERSION = 1
97
+ API_MAX_VERSION = 3
98
+ # API_BASE_PATH defaults to "api/v{version}/"
99
+ ```
100
+
101
+ Import modules containing endpoint declarations before including the generated patterns:
102
+
103
+ ```python
104
+ # project/urls.py
105
+ from django.urls import include, path
106
+
107
+ from orders import views as _order_views # noqa: F401
108
+ from django_api_versioning.urls import urlpatterns as api_urlpatterns
109
+
110
+ urlpatterns = [
111
+ path("", include(api_urlpatterns)),
112
+ ]
113
+ ```
114
+
115
+ Run the route-matrix check:
116
+
117
+ ```bash
118
+ python manage.py check_versions
119
+ ```
120
+
121
+ ## Registration options
122
+
123
+ | Declaration | Routes created |
124
+ | --- | --- |
125
+ | `@endpoint("orders/", version=2)` | v2 through `API_MAX_VERSION` |
126
+ | `@endpoint("orders/", versions=[1, 3, 5])` | Only v1, v3, and v5 |
127
+ | `@endpoint("health/")` | One unversioned route |
128
+
129
+ For an inclusive range, use `ver_range(1, 3)`. Other APIs include `api_reverse()` for version-aware URL reversal and `assert_version_matrix()` for regression tests.
130
+
131
+ See the [versioning contract](https://github.com/mojtaba-arvin/django-api-versioning/blob/main/docs/reference/versioning-contract.md) for exact URL construction, import order, collision precedence, validation, and edge cases.
132
+
133
+ ## DRF ViewSet boundary
134
+
135
+ A DRF `ViewSet` or `ModelViewSet` cannot be passed directly to `@endpoint`, because `as_view()` requires an action mapping. You can register a configured callable for an individual route, but this does not create the full router-managed set of list, detail, and custom-action routes. Use DRF's `DefaultRouter` or `SimpleRouter` when you need standard ViewSet routing.
136
+
137
+ See [ViewSet support and limitations](https://mojtaba-arvin.github.io/django-api-versioning/articles/025-django-api-versioning-viewset-support-limitations/).
138
+
139
+ ## Requirements
140
+
141
+ - Python 3.10+
142
+ - Django 4.2+
143
+ - Django REST Framework is optional.
144
+
145
+ The configured CI matrix covers selected combinations of Python 3.10–3.15 and Django 4.2, 5.2, 6.0, and 6.1. See [tox.ini](https://github.com/mojtaba-arvin/django-api-versioning/blob/main/tox.ini) for configured environments and [GitHub Actions](https://github.com/mojtaba-arvin/django-api-versioning/actions) for results tied to a specific commit.
146
+
147
+ ## Upgrading to 1.0.0
148
+
149
+ Version 1.0.0 tightened API lifecycle configuration and changed the `Deprecation` response header format. If you use `API_VERSION_LIFECYCLE`:
150
+
151
+ - Every entry must have a `status` of `active`, `deprecated`, or `retired`.
152
+ - A deprecated version must define `deprecated_at` as an ISO 8601 date or datetime.
153
+ - A retired version must define a `sunset` date.
154
+ - The `Deprecation` header now uses the RFC 9745 date-valued Structured Field (for example, `Deprecation: @1767225600`), not the legacy `Deprecation: true` value.
155
+
156
+ For migration steps, see the [1.0.0 changelog](https://github.com/mojtaba-arvin/django-api-versioning/blob/main/CHANGELOG.md#100---2026-11-16).
157
+
158
+ ## Documentation
159
+
160
+ - [Django API Versioning documentation and interactive playground](https://mojtaba-arvin.github.io/django-api-versioning/) — overview, examples, lifecycle demonstration, and guides.
161
+ - [API reference](https://mojtaba-arvin.github.io/django-api-versioning/reference/) — settings, decorators, URL reversal, validation, and management commands.
162
+ - [Routing contract](https://github.com/mojtaba-arvin/django-api-versioning/blob/main/docs/reference/versioning-contract.md) — implementation-backed behavior and limitations.
163
+ - [DRF integration guide](https://mojtaba-arvin.github.io/django-api-versioning/articles/013-drf-version-negotiation-vs-endpoint-registration/).
164
+ - [Python and Django compatibility guide](https://mojtaba-arvin.github.io/django-api-versioning/articles/024-django-api-versioning-supported-django-python-versions/).
165
+ - [Documentation source map](https://github.com/mojtaba-arvin/django-api-versioning/blob/main/docs/README.md).
166
+
167
+ ## Contributing
168
+
169
+ Bug reports, corrections, and pull requests are welcome. Read the [contribution guidelines](https://github.com/mojtaba-arvin/django-api-versioning/blob/main/CONTRIBUTING.md) and [security policy](https://github.com/mojtaba-arvin/django-api-versioning/blob/main/SECURITY.md).
170
+
171
+ ## License
172
+
173
+ Released under the [MIT License](https://github.com/mojtaba-arvin/django-api-versioning/blob/main/LICENSE).
@@ -0,0 +1,223 @@
1
+ Metadata-Version: 2.4
2
+ Name: django-api-versioning
3
+ Version: 1.0.1
4
+ Summary: URL-path API versioning for Django and Django REST Framework with decorator-based endpoint registration and forward route inheritance.
5
+ Author-email: Mojtaba Arvin <ArvinDevDay@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://mojtaba-arvin.github.io/django-api-versioning/
8
+ Project-URL: Documentation, https://mojtaba-arvin.github.io/django-api-versioning/reference/
9
+ Project-URL: Source, https://github.com/mojtaba-arvin/django-api-versioning
10
+ Project-URL: Issues, https://github.com/mojtaba-arvin/django-api-versioning/issues
11
+ Project-URL: Changelog, https://github.com/mojtaba-arvin/django-api-versioning/blob/main/CHANGELOG.md
12
+ Project-URL: Security, https://github.com/mojtaba-arvin/django-api-versioning/blob/main/SECURITY.md
13
+ Keywords: django api versioning,django rest framework api versioning,drf versioning,url path api versioning,versioned url routing,endpoint registration,version-specific django views,django-api-versioning
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Programming Language :: Python :: 3.15
21
+ Classifier: Framework :: Django
22
+ Classifier: Framework :: Django :: 4.2
23
+ Classifier: Framework :: Django :: 5.2
24
+ Classifier: Framework :: Django :: 6.0
25
+ Classifier: Framework :: Django :: 6.1
26
+ Classifier: Development Status :: 5 - Production/Stable
27
+ Classifier: Intended Audience :: Developers
28
+ Classifier: Operating System :: OS Independent
29
+ Classifier: Topic :: Internet :: WWW/HTTP
30
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
31
+ Classifier: Typing :: Typed
32
+ Requires-Python: >=3.10
33
+ Description-Content-Type: text/markdown
34
+ License-File: LICENSE
35
+ Requires-Dist: Django>=4.2
36
+ Provides-Extra: dev
37
+ Requires-Dist: black>=26.10.1; extra == "dev"
38
+ Requires-Dist: flake8>=7.4.1; extra == "dev"
39
+ Requires-Dist: isort>=9.0.2; extra == "dev"
40
+ Requires-Dist: mypy>=2.4.0; extra == "dev"
41
+ Requires-Dist: pytest>=9.2.0; extra == "dev"
42
+ Requires-Dist: pytest-django>=4.14.0; extra == "dev"
43
+ Requires-Dist: pytest-cov>=7.1.0; extra == "dev"
44
+ Requires-Dist: pre-commit>=4.7.0; python_version >= "3.11" and extra == "dev"
45
+ Requires-Dist: twine>=7.0.0; extra == "dev"
46
+ Requires-Dist: build>=1.6.1; extra == "dev"
47
+ Requires-Dist: djangorestframework>=3.18; extra == "dev"
48
+ Requires-Dist: tomli>=2.0.1; python_version < "3.11" and extra == "dev"
49
+ Dynamic: license-file
50
+
51
+ <p align="center">
52
+ <a href="https://mojtaba-arvin.github.io/django-api-versioning/">
53
+ <img src="https://raw.githubusercontent.com/mojtaba-arvin/django-api-versioning/main/website/public/favicon.svg" alt="Django API Versioning logo" width="64" height="64">
54
+ </a>
55
+ </p>
56
+
57
+ # Django API Versioning
58
+
59
+ [![PyPI version](https://img.shields.io/pypi/v/django-api-versioning?logo=pypi&logoColor=white)](https://pypi.org/project/django-api-versioning/)
60
+ [![Python versions](https://img.shields.io/pypi/pyversions/django-api-versioning.svg)](https://pypi.org/project/django-api-versioning/)
61
+ [![Django versions](https://img.shields.io/badge/django-4.2%20%7C%205.2%20%7C%206.0%20%7C%206.1-blue)](https://github.com/mojtaba-arvin/django-api-versioning/blob/main/tox.ini)
62
+ [![Python tests](https://github.com/mojtaba-arvin/django-api-versioning/actions/workflows/tests.yml/badge.svg)](https://github.com/mojtaba-arvin/django-api-versioning/actions/workflows/tests.yml)
63
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/mojtaba-arvin/django-api-versioning/blob/main/LICENSE)
64
+
65
+ **Version your Django API by endpoint, not by duplicating URL patterns.** Register a view once; unchanged routes carry forward to later API versions, and a newer declaration replaces the implementation from that version onward.
66
+
67
+ [Explore Django API Versioning — documentation, examples, and interactive playground](https://mojtaba-arvin.github.io/django-api-versioning/) · [Install django-api-versioning from PyPI](https://pypi.org/project/django-api-versioning/)
68
+
69
+ ## See how it works
70
+
71
+ Install the package and Django REST Framework:
72
+
73
+ ```bash
74
+ pip install django-api-versioning djangorestframework
75
+ ```
76
+
77
+ Declare only the versions where an endpoint's behavior changes:
78
+
79
+ ```python
80
+ from rest_framework.response import Response
81
+ from rest_framework.views import APIView
82
+
83
+ from django_api_versioning import endpoint
84
+
85
+
86
+ @endpoint("orders/", version=1, view_name="order-list")
87
+ class OrderListV1(APIView):
88
+ def get(self, request):
89
+ return Response({"total": "19.99"})
90
+
91
+
92
+ @endpoint("orders/", version=2, view_name="order-list")
93
+ class OrderListV2(APIView):
94
+ def get(self, request):
95
+ return Response({"total": 1999, "currency": "USD"})
96
+ ```
97
+
98
+ With `API_MAX_VERSION = 3`, the generated routes are:
99
+
100
+ | Request | View |
101
+ | --- | --- |
102
+ | `GET /api/v1/orders/` | `OrderListV1` |
103
+ | `GET /api/v2/orders/` | `OrderListV2` |
104
+ | `GET /api/v3/orders/` | `OrderListV2` |
105
+
106
+ The v1 view serves v1 until another declaration replaces it. The v2 view then serves v2 and v3. **You write a new view when the endpoint changes—not another copy of every unchanged route.**
107
+
108
+ For the complete setup, including Django settings and URL configuration, see the [Django API Versioning getting-started guide](https://mojtaba-arvin.github.io/django-api-versioning/articles/022-django-api-versioning-how-does-it-work/).
109
+
110
+ ## What problem does it solve?
111
+
112
+ In a growing API, only some endpoints change between releases. Manually maintaining a separate URL configuration for every version can repeat registrations and obscure which implementation handles each version.
113
+
114
+ Django API Versioning makes that mapping explicit with `@endpoint`:
115
+
116
+ - **Forward route inheritance:** `version=1` registers the endpoint from v1 through `API_MAX_VERSION`.
117
+ - **Version-specific replacement:** a v2 declaration takes over from v2 onward; earlier versions retain the v1 implementation.
118
+ - **Explicit registration:** use `versions=[...]` or `ver_range(...)` when an endpoint should exist only in selected versions.
119
+ - **Visibility:** inspect the generated route matrix with `check_versions` and test it with `assert_version_matrix()`.
120
+
121
+ This is inheritance of route registrations, not automatic backward compatibility. Your application remains responsible for response schemas, business behavior, and compatibility tests.
122
+
123
+ ## Why use it with Django REST Framework?
124
+
125
+ DRF already provides versioning schemes to identify the requested API version, for example through `request.version`. This package solves a related but different problem: **mapping versioned URL paths to specific view implementations and carrying unchanged registrations forward**.
126
+
127
+ Use DRF's built-in versioning when request-version identification is all you need. Use this package when you want declarative version-to-view routing and an inspectable route matrix. They can be used together; this package does not automatically populate `request.version`.
128
+
129
+ DRF is optional. The package also supports Django function-based and class-based views. For a Django-only project, install just:
130
+
131
+ ```bash
132
+ pip install django-api-versioning
133
+ ```
134
+
135
+ ## Quick configuration
136
+
137
+ Add the package (and DRF, if used) to `INSTALLED_APPS` and configure the supported version range:
138
+
139
+ ```python
140
+ # settings.py
141
+ INSTALLED_APPS = [
142
+ "rest_framework", # omit when using Django-native views only
143
+ "django_api_versioning",
144
+ ]
145
+
146
+ API_MIN_VERSION = 1
147
+ API_MAX_VERSION = 3
148
+ # API_BASE_PATH defaults to "api/v{version}/"
149
+ ```
150
+
151
+ Import modules containing endpoint declarations before including the generated patterns:
152
+
153
+ ```python
154
+ # project/urls.py
155
+ from django.urls import include, path
156
+
157
+ from orders import views as _order_views # noqa: F401
158
+ from django_api_versioning.urls import urlpatterns as api_urlpatterns
159
+
160
+ urlpatterns = [
161
+ path("", include(api_urlpatterns)),
162
+ ]
163
+ ```
164
+
165
+ Run the route-matrix check:
166
+
167
+ ```bash
168
+ python manage.py check_versions
169
+ ```
170
+
171
+ ## Registration options
172
+
173
+ | Declaration | Routes created |
174
+ | --- | --- |
175
+ | `@endpoint("orders/", version=2)` | v2 through `API_MAX_VERSION` |
176
+ | `@endpoint("orders/", versions=[1, 3, 5])` | Only v1, v3, and v5 |
177
+ | `@endpoint("health/")` | One unversioned route |
178
+
179
+ For an inclusive range, use `ver_range(1, 3)`. Other APIs include `api_reverse()` for version-aware URL reversal and `assert_version_matrix()` for regression tests.
180
+
181
+ See the [versioning contract](https://github.com/mojtaba-arvin/django-api-versioning/blob/main/docs/reference/versioning-contract.md) for exact URL construction, import order, collision precedence, validation, and edge cases.
182
+
183
+ ## DRF ViewSet boundary
184
+
185
+ A DRF `ViewSet` or `ModelViewSet` cannot be passed directly to `@endpoint`, because `as_view()` requires an action mapping. You can register a configured callable for an individual route, but this does not create the full router-managed set of list, detail, and custom-action routes. Use DRF's `DefaultRouter` or `SimpleRouter` when you need standard ViewSet routing.
186
+
187
+ See [ViewSet support and limitations](https://mojtaba-arvin.github.io/django-api-versioning/articles/025-django-api-versioning-viewset-support-limitations/).
188
+
189
+ ## Requirements
190
+
191
+ - Python 3.10+
192
+ - Django 4.2+
193
+ - Django REST Framework is optional.
194
+
195
+ The configured CI matrix covers selected combinations of Python 3.10–3.15 and Django 4.2, 5.2, 6.0, and 6.1. See [tox.ini](https://github.com/mojtaba-arvin/django-api-versioning/blob/main/tox.ini) for configured environments and [GitHub Actions](https://github.com/mojtaba-arvin/django-api-versioning/actions) for results tied to a specific commit.
196
+
197
+ ## Upgrading to 1.0.0
198
+
199
+ Version 1.0.0 tightened API lifecycle configuration and changed the `Deprecation` response header format. If you use `API_VERSION_LIFECYCLE`:
200
+
201
+ - Every entry must have a `status` of `active`, `deprecated`, or `retired`.
202
+ - A deprecated version must define `deprecated_at` as an ISO 8601 date or datetime.
203
+ - A retired version must define a `sunset` date.
204
+ - The `Deprecation` header now uses the RFC 9745 date-valued Structured Field (for example, `Deprecation: @1767225600`), not the legacy `Deprecation: true` value.
205
+
206
+ For migration steps, see the [1.0.0 changelog](https://github.com/mojtaba-arvin/django-api-versioning/blob/main/CHANGELOG.md#100---2026-11-16).
207
+
208
+ ## Documentation
209
+
210
+ - [Django API Versioning documentation and interactive playground](https://mojtaba-arvin.github.io/django-api-versioning/) — overview, examples, lifecycle demonstration, and guides.
211
+ - [API reference](https://mojtaba-arvin.github.io/django-api-versioning/reference/) — settings, decorators, URL reversal, validation, and management commands.
212
+ - [Routing contract](https://github.com/mojtaba-arvin/django-api-versioning/blob/main/docs/reference/versioning-contract.md) — implementation-backed behavior and limitations.
213
+ - [DRF integration guide](https://mojtaba-arvin.github.io/django-api-versioning/articles/013-drf-version-negotiation-vs-endpoint-registration/).
214
+ - [Python and Django compatibility guide](https://mojtaba-arvin.github.io/django-api-versioning/articles/024-django-api-versioning-supported-django-python-versions/).
215
+ - [Documentation source map](https://github.com/mojtaba-arvin/django-api-versioning/blob/main/docs/README.md).
216
+
217
+ ## Contributing
218
+
219
+ Bug reports, corrections, and pull requests are welcome. Read the [contribution guidelines](https://github.com/mojtaba-arvin/django-api-versioning/blob/main/CONTRIBUTING.md) and [security policy](https://github.com/mojtaba-arvin/django-api-versioning/blob/main/SECURITY.md).
220
+
221
+ ## License
222
+
223
+ Released under the [MIT License](https://github.com/mojtaba-arvin/django-api-versioning/blob/main/LICENSE).