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
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:
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
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,
Working on a Django project? Check out my book Speed Up Your Django Tests which covers loads of best practices so you can write faster, more accurate tests.
One summary email a week, no spam, I pinky promise.
© 2021 All rights reserved.