← Articles

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:

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.

DependencyDeclarationPurpose
Python>=3.10Required Python interpreter
Django>=4.2Runtime dependency
Django REST Framework>=3.18Optional development dependency

The development dependency group in pyproject.toml includes:

toml
[project.optional-dependencies]
dev = [
    # Other development tools
    "djangorestframework>=3.18",
]

The repository's requirements-dev.txt specifies:

text
djangorestframework>=3.18.3

The requirements-dev.txt file also includes the project's base requirements through:

text
-r requirements.txt

The base requirements.txt declares:

text
Django>=4.2

These 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:

toml
requires-python = ">=3.10"

Its package classifiers list the following Python versions:

Python versionListed in package classifiers?
3.9No
3.10Yes
3.11Yes
3.12Yes
3.13Yes
3.14Yes
3.15Yes

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:

toml
dependencies = [
    "Django>=4.2",
]

Its package classifiers list these Django versions:

Django versionListed in package classifiers?
4.2Yes
5.2Yes
6.0Yes
6.1Yes

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:

  1. Checks out the exact commit associated with the event.
  2. Sets up Python 3.15.
  3. Installs the test dependencies from requirements-ci.txt.
  4. Runs the package unit-test directory.
  5. Runs the standalone Django integration-test project.

The commands executed by the workflow are:

bash
python -m pytest --capture=no tests
python -m pytest --capture=no -c integration_test_project/pytest.ini integration_test_project

The 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 versionPython versionsTest environments
4.23.10, 3.11, 3.123
5.23.10, 3.11, 3.12, 3.13, 3.145
6.03.12, 3.13, 3.143
6.13.12, 3.13, 3.14, 3.154

This results in 15 configured test environments.

Each tox test environment runs both the package unit tests and the Django integration tests:

bash
python -m pytest tests --maxfail=1 --disable-warnings -q
python -m pytest integration_test_project --maxfail=1 --disable-warnings -q

The .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:

  1. Open the relevant Python tests workflow, compatibility matrix workflow, and package artifact workflow.
  2. Select a run whose source commit SHA matches the code you are evaluating.
  3. Check every required job's conclusion; a queued, skipped, cancelled, or failed job is not a passing result.
  4. For a pull request, use the PR gate result 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:

bash
python --version

Check Django:

bash
python -m django --version

If your application uses DRF, check its installed version:

bash
python -m pip show djangorestframework

You can also inspect the installed versions from a Python shell:

python
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:

bash
python -m pip install django-api-versioning

Pip 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:

bash
python -m pip install djangorestframework

Choose 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:

text
django-api-versioning

Pip resolves the package's declared runtime dependencies, including Django.

If your application also uses DRF, declare it separately:

text
django-api-versioning
djangorestframework

You can specify an explicit DRF constraint based on your application's compatibility requirements:

text
django-api-versioning
djangorestframework

The 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:

bash
python --version

Make sure your virtual environment uses Python 3.10 or newer.

Dependency Resolution Errors

If pip reports a dependency conflict, inspect the installed versions:

bash
python -m pip show Django djangorestframework django-api-versioning

You can also ask pip to check for incompatible installed dependencies:

bash
python -m pip check

Remember 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:

bash
python -m pip show django-api-versioning

Then test the public imports:

python
from django_api_versioning import endpoint, ver_range, api_reverse

These 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.