Article 024
Python and Django Compatibility
Review django-api-versioning Python and Django requirements, package classifiers, GitHub Actions tests, and the separately configured tox compatibility matrix.
Before installing a Django package, distinguish its declared runtime dependencies from the development tools and dependencies used by the package maintainers.
For django-api-versioning, Django is a runtime dependency, while Django REST Framework (DRF) is not required by the core package. DRF is used by the project's integration examples and development and testing setup.
This guide separates declared runtime requirements, package classifiers, configured CI environments, and actual workflow results. These are related but different kinds of evidence; use the source links in each section to check the current repository state.
This article examines the package's declared requirements, its package classifiers, and the environment used by its CI workflow. These represent different aspects of compatibility and should not be treated as interchangeable.
Runtime Requirements
The package declares its runtime requirements in pyproject.toml. These declarations are the source of truth for the minimum Python version and required Django dependency.
See the current package metadata rather than relying on version-specific values copied into this article.
The package metadata declares these requirements in pyproject.toml:
requires-python = ">=3.10"
dependencies = [
"Django>=4.2",
]Django REST Framework is not included in the package's runtime dependencies.
If your application uses DRF, install it as an application dependency. Its required version depends on your application's needs and the compatibility of the DRF release with your Django version.
See the current package metadata.
Runtime Dependencies vs. Development Dependencies
The package separates runtime dependencies from optional development dependencies.
| Dependency | Declaration | Purpose |
|---|---|---|
| Python | >=3.10 | Required Python interpreter |
| Django | >=4.2 | Runtime dependency |
| Django REST Framework | >=3.18 | Optional development dependency |
The development dependency group in pyproject.toml includes:
[project.optional-dependencies]
dev = [
# Other development tools
"djangorestframework>=3.18",
]The repository's requirements-dev.txt specifies:
djangorestframework>=3.18.3The requirements-dev.txt file also includes the project's base requirements through:
-r requirements.txtThe base requirements.txt declares:
Django>=4.2These DRF constraints describe the project's development and testing environment. They do not establish a minimum DRF version required by the published package.
If your application uses Django REST Framework, declare it in your own dependency configuration rather than treating it as a runtime requirement of django-api-versioning.
Python Version Metadata
The package declares Python 3.10 or newer:
requires-python = ">=3.10"Its package classifiers list the following Python versions:
| Python version | Listed in package classifiers? |
|---|---|
| 3.9 | No |
| 3.10 | Yes |
| 3.11 | Yes |
| 3.12 | Yes |
| 3.13 | Yes |
| 3.14 | Yes |
| 3.15 | Yes |
The requires-python field defines the minimum Python version accepted by the package metadata.
Classifiers provide additional package metadata. They should not be interpreted as proof that every listed Python version is covered by an automated test run.
In particular, declaring Python >=3.10 does not establish that every future Python release has been tested.
Django Version Metadata
The package declares Django 4.2 or newer:
dependencies = [
"Django>=4.2",
]Its package classifiers list these Django versions:
| Django version | Listed in package classifiers? |
|---|---|
| 4.2 | Yes |
| 5.2 | Yes |
| 6.0 | Yes |
| 6.1 | Yes |
These classifiers describe the versions associated with the package metadata. They do not constitute a CI test matrix or independently prove compatibility with every listed release.
The actual Django version installed during a test run depends on the dependency constraints and the versions resolved by pip at that time.
The compatibility matrix still includes Django 4.2 to detect regressions for existing installations, but that does not make 4.2 a supported production target today. Django 4.2 reached the end of extended support on 7 April 2026 and no longer receives security fixes. For new deployments, choose a currently supported Django series; Django 5.2 is the current LTS line and has extended support through April 2028. Django 6.0 and 6.1 are also currently supported, with shorter support windows.
Check Django's live supported-versions table before selecting a deployment version, because support windows change independently of this package's CI matrix. The Django team explicitly announced the end of Django 4.2 extended support and recommends upgrading to Django 5.2 or later.
What Do GitHub Actions and tox Actually Test?
The repository has separate workflows for the focused Python test suites and the broader Python/Django compatibility matrix. They serve different purposes and should not be treated as the same test configuration.
GitHub Actions Python test workflow
The .github/workflows/tests.yml workflow runs on a GitHub-hosted Ubuntu runner. It does not build the project's development Docker image.
For its focused test job, the workflow:
- Checks out the exact commit associated with the event.
- Sets up Python 3.15.
- Installs the test dependencies from
requirements-ci.txt. - Runs the package unit-test directory.
- Runs the standalone Django integration-test project.
The commands executed by the workflow are:
python -m pytest --capture=no tests
python -m pytest --capture=no -c integration_test_project/pytest.ini integration_test_projectThe integration suite uses its own pytest configuration. The root pytest.ini points to tests, so running the root pytest command alone is not equivalent to running both suites.
The reusable workflow supports workflow_call, can be started manually with workflow_dispatch, and runs on relevant pushes to main. For pull requests, the repository's always-running PR gate invokes this workflow when the changed paths require Python tests. The direct workflow definition does not subscribe to pull_request events itself.
The repository's root Dockerfile and entrypoint.sh remain part of the local development workflow. The default entrypoint runs the unit and integration suites and validates built package artifacts, but the current GitHub Actions Python test workflow does not invoke that Docker entrypoint.
Configured tox compatibility matrix
The repository separately defines the following environments in tox.ini:
| Django version | Python versions | Test environments |
|---|---|---|
| 4.2 | 3.10, 3.11, 3.12 | 3 |
| 5.2 | 3.10, 3.11, 3.12, 3.13, 3.14 | 5 |
| 6.0 | 3.12, 3.13, 3.14 | 3 |
| 6.1 | 3.12, 3.13, 3.14, 3.15 | 4 |
This results in 15 configured test environments.
Each tox test environment runs both the package unit tests and the Django integration tests:
python -m pytest tests --maxfail=1 --disable-warnings -q
python -m pytest integration_test_project --maxfail=1 --disable-warnings -qThe .github/workflows/compatibility.yml workflow supports relevant pushes to main, manual workflow_dispatch, and reusable workflow_call from the pull-request gate and tag-based publish workflow. For pull requests, the PR gate invokes the compatibility workflow when the changed paths affect the Python/Django matrix. Documentation-only or website-only edits do not require this matrix. The workflow also runs two platform smoke jobs (Windows and macOS on Python 3.12/Django 5.2) and validates that the GitHub Actions environment list matches tox.ini.
The tox configuration also defines one lint environment that runs:
- flake8
- black --check
- isort --check-only
The tox configuration therefore contains 15 Python/Django test environments plus one lint environment. The compatibility workflow adds the two platform smoke jobs and one matrix-validation job; these are not additional tox environments.
Checking actual CI results
The matrix in tox.ini describes which environments are configured; it does not prove that they passed for a particular commit. To evaluate a release or a proposed change:
- Open the relevant Python tests workflow, compatibility matrix workflow, and package artifact workflow.
- Select a run whose source commit SHA matches the code you are evaluating.
- Check every required job's conclusion; a queued, skipped, cancelled, or failed job is not a passing result.
- For a pull request, use the
PR gateresult for its latest head commit. The gate invokes the checks required by the changed paths.
The tag-based publishing workflow runs the compatibility matrix and verifies the wheel and source distribution before publishing to PyPI. A successful build on a different commit is not evidence for the tag being evaluated.
The repository does not maintain a rolling compatibility-results document. The v0.3.8 compatibility report is historical evidence for that release only; do not use it as current v1.0.0 test results.
Workflow results are commit-specific. Dependency resolution may also change between runs when the configuration specifies a version range instead of an exact pin.
Dependency resolution
The tox configuration installs Django using environment-specific version constraints.
DRF is installed as a development dependency. The tox configuration does not pin DRF to an exact version, so its resolved version may change between executions.
The DRF dependency in the tox environments is not pinned to one exact version. Its resolved version can therefore differ between workflow runs. A successful matrix run verifies the concrete dependency set resolved during that run, not every future DRF release.
For an accurate compatibility assessment, distinguish:
- Runtime dependency requirements.
- Package classifiers.
- Focused GitHub Actions test execution.
- Configured tox environments.
- Recorded test execution results.
- Package artifact validation.
Checking Your Installed Versions
You can inspect the versions installed in your active Python environment.
Check Python:
python --versionCheck Django:
python -m django --versionIf your application uses DRF, check its installed version:
python -m pip show djangorestframeworkYou can also inspect the installed versions from a Python shell:
import sys
import django
print(f"Python: {sys.version}")
print(f"Django: {django.get_version()}")
try:
import rest_framework
print(f"DRF: {rest_framework.VERSION}")
except ImportError:
print("DRF is not installed")The DRF check is optional because django-api-versioning does not require DRF as a runtime dependency.
Installing the Package
The published package is available on PyPI.
Install the package with pip:
python -m pip install django-api-versioningPip reads the package metadata and resolves its declared runtime dependencies, including Django.
You do not need to install Django REST Framework solely to install django-api-versioning.
If your application uses DRF, install it separately:
python -m pip install djangorestframeworkChoose a DRF version compatible with the Django version used by your application.
Declaring Application Dependencies
For an application that uses django-api-versioning but does not use Django REST Framework, a minimal requirements.txt can be:
django-api-versioningPip resolves the package's declared runtime dependencies, including Django.
If your application also uses DRF, declare it separately:
django-api-versioning
djangorestframeworkYou can specify an explicit DRF constraint based on your application's compatibility requirements:
django-api-versioning
djangorestframeworkThe DRF constraint in this example is an application-level choice. It is not a runtime requirement declared by django-api-versioning.
Troubleshooting Compatibility Issues
Unsupported Python Version
If your Python version is below 3.10, it does not meet the package's declared minimum requirement.
Check the active interpreter:
python --versionMake sure your virtual environment uses Python 3.10 or newer.
Dependency Resolution Errors
If pip reports a dependency conflict, inspect the installed versions:
python -m pip show Django djangorestframework django-api-versioningYou can also ask pip to check for incompatible installed dependencies:
python -m pip checkRemember that DRF is an application dependency when your application uses it, not a required runtime dependency of this package.
Import Errors
If the package is installed but Python cannot import it, verify that it was installed in the same environment used to run Django:
python -m pip show django-api-versioningThen test the public imports:
from django_api_versioning import endpoint, ver_range, api_reverseThese are the package's public imports. For the package's routing behavior and configuration semantics, see the versioning contract.
Important Compatibility Considerations
When evaluating compatibility, keep these distinctions in mind:
- Python requirement: The package declares Python
>=3.10. - Django requirement: The package declares Django
>=4.2. - DRF dependency: DRF is not a runtime dependency of the package. It is included in the development dependencies.
- Package classifiers: Listed Python and Django versions are metadata, not proof of automated test coverage.
- CI configuration: The focused Python workflow runs the unit and integration suites; the compatibility workflow executes the configured tox matrix plus platform smoke checks. Check Python test runs and compatibility matrix runs for commit-specific results.
- Dependency resolution: Minimum-version constraints do not guarantee that every future build uses the same dependency versions.
Meeting the declared minimum requirements is necessary, but it does not prove that every possible combination of newer dependency versions has been tested.
For production deployments, verify the dependency combination used by your application and run your own integration tests.
Conclusion
The package's runtime requirements are declared in its project metadata. Django REST Framework is not required to install the core package; it is used by the project's integration examples and development and testing setup.
For configured Python and Django combinations, consult tox.ini. For actual test outcomes, consult the compatibility workflow history and verify that the run's source commit matches the version you use.
Package classifiers, dependency metadata, and CI configuration describe different aspects of compatibility. Review all three before drawing conclusions about supported and tested environments.
Further Reading
To inspect the package source, releases, and implementation details, visit the django-api-versioning repository.