Introducing django-version-checks

2020-12-14 Be on your guard, like this hairy armadillo...

It can be tricky to ensure all the environments that your project runs on use the same versions of Python, PostgreSQL, and other external dependencies. Often development, CI, and cloud environments have different configuration systems, making them hard to keep in sync. And coordinating between all your team members to upgrade their local environments can be complicated, as upgrade emails or instant messages get forgotten if they are away on holiday, working on other projects, etc. And using the wrong versions of external dependencies can lead to hard-to-debug errors, wasting time to find such a simple fix.

I’ve solved this problem several times on different projects over the years with custom Django system checks. These can tell you early in Django’s startup process the environment has the incorrect versions. Today I’ve released a package containing configurable versions of such checks, called django-version-checks. You activate the checks by specifying the allowed versions in PEP 440 specifiers, the same format that pip uses.

For example, imagine you are using the cutting-edge versions of Python and MariaDB. To ensure all environments use these versions, or compatible bug fix releases, you can install django-version-checks and add this to your settings file:

    "mysql": "~=10.5.8",
    "python": "~=3.9.1",

Any environments whose dependencies don’t match these specifiers will see a system check error. For example, if I had left my development environment on Python 3.8 and tried to run migrate:

$ python migrate
SystemCheckError: System check identified some issues:

?: (dvc.E003) The current version of Python (3.8.5) does not match the specified range (~=3.9.1).

django-version-checks comes with checks for Python, PostgreSQL, MariaDB/MySQL and SQLite, and I’m open to adding more in the future. For more information, see its README on PyPI.


Go forth and check all those versions,


Want better tests? Check out my book Speed Up Your Django Tests which teaches you to write faster, more accurate tests.

Subscribe via RSS, Twitter, or email:

One summary email a week, no spam, I pinky promise.

Related posts:

Tags: django