System checks for your project's environment.

Overview

django-version-checks

https://img.shields.io/github/workflow/status/adamchainz/django-version-checks/CI/main?style=for-the-badge https://img.shields.io/coveralls/github/adamchainz/django-version-checks/main?style=for-the-badge https://img.shields.io/pypi/v/django-version-checks.svg?style=for-the-badge https://img.shields.io/badge/code%20style-black-000000.svg?style=for-the-badge pre-commit

System checks for your project's environment.

Requirements

Python 3.6 to 3.9 supported.

Django 2.2 to 3.2 supported.


Are your tests slow? Check out my book Speed Up Your Django Tests which covers loads of best practices so you can write faster, more accurate tests.


Installation

First, install with pip:

python -m pip install django-version-checks

Second, add the app to your INSTALLED_APPS setting:

INSTALLED_APPS = [
    ...
    "django_version_checks",
    ...
]

Third, add a VERSION_CHECKS setting with the version checks you want to enforce (as documented below). For example:

VERSION_CHECKS = {
    "python": "==3.9.*",
}

Usage

See also the introductory blog post.

django-version-checks adds several system checks that can help ensure that the current environment has the right versions of Python, databases, etc. This is useful when coordinating upgrades across all your infrastructure.

Note that django-version-checks does not check the versions of your Python dependencies. This is because such checks need doing at the start of the Python process, in your manage.py file, before Django imports your apps. Any mismatched versions are likely to cause import time problems, before django-version-checks’ system checks can execute. To add checks on your Python dependencies, check out pip-lock.

Checks use the PEP 440 specifier format via the packaging module. This is the same format used by pip, and allows some flexibility in specifying valid version ranges. The ~= operator is particularly useful. For example, you can use ~=3.9.1 to mean “3.9.1+, but less than 3.10.0”, allowing environments to take on patch releases without changes, but nothing more.

The individual checks are documented below. Each occupies a key in the VERSION_CHECKS dictionary, and documents its supported types for specifiers. If a check is misconfigured with a bad type or specifier you will see one of these system check errors:

  • dvc.E001: <check> is misconfigured. Expected a <type> but got <value>.
  • dvc.E002: <check> is misconfigured. <value> is not a valid PEP440 specifier.

mysql check

This check compares the current version of MariaDB/MySQL to the given specifier. The range can specified either as a single string:

VERSION_CHECKS = {
    "mysql": "~=10.5.8",
}

...or as a dictionary mapping database aliases to their specifiers:

VERSION_CHECKS = {
    "postgresql": {
        "default": "~=10.5.8",
        "analytics": "~=10.4.17",
    },
}

Note: as a database check, Django will only run this during migrate or when using check --database (Django 3.1+) / check --tags database (Django <3.1). See (docs).

If this check fails, the system check will report:

  • dvc.E005: The current version of MariaDB/MySQL (<version>) for the <alias> database connection does not match the specified range (<range>).

python check

This check compares the current version of Python to the given single specifier:

VERSION_CHECKS = {
    "python": "~=3.9.1",
}

If this check fails, the system check will report:

  • dvc.E003: The current version of Python (<version>) does not match the specified range (<range>).

postgresql check

This check compares the current version of PostgreSQL to the given specifier. The range can specified either as a single string:

VERSION_CHECKS = {
    "postgresql": "~=12.2",
}

...or as a dictionary mapping database aliases to their specifiers:

VERSION_CHECKS = {
    "postgresql": {
        "default": "~=12.2",
        "analytics": "~=13.1",
    },
}

Note: as a database check, Django will only run this during migrate or when using check --database (Django 3.1+) / check --tags database (Django <3.1). See (docs).

If this check fails, the system check will report:

  • dvc.E004: The current version of PostgreSQL (<version>) for the <alias> database connection does not match the specified range (<range>).

sqlite check

This check compares the current version of SQLite to the given single specifier:

VERSION_CHECKS = {
    "sqlite": "~=12.2",
}

Note: as a database check, Django will only run this during migrate or when using check --database (Django 3.1+) / check --tags database (Django <3.1). See (docs).

If this check fails, the system check will report:

  • dvc.E006: The current version of SQLite (<version>) does not match the specified range (<range>).

Example Upgrade

Let’s walk through using django-version-checks to upgrade Python from version 3.8 to 3.9. We have an infrastructure consisting of CI, staging, and production environments, and several developers’ development machines.

First, we add a pre-existing check to ensure that all environments are on Python 3.8:

VERSION_CHECKS = {
    "python": "~=3.8.6",
}

Second, we rewrite the specifier to allow versions of Python 3.9:

VERSION_CHECKS = {
    "python": ">=3.8.6,<3.10.0",
}

Third, we upgrade our infrastructure. We’d probably upgrade in the order: CI, development environments, staging, production. Each environment should have an automated run of manage.py check, as per the Django deployment checklist.

Fourth, we change the specifier again to allow Python 3.9 only:

VERSION_CHECKS = {
    "python": "~=3.9.1",
}

And we’re upgraded! 🎉

Owner
Adam Johnson
🦄 @django technical board member 🇬🇧 @djangolondon co-organizer ✍ AWS/Django/Python Author and Consultant
Adam Johnson
django social media app with real time features

django-social-media django social media app with these features: signup, login and old registered users are saved by cookies posts, comments, replies,

8 Apr 30, 2022
PEP-484 type hints bindings for the Django web framework

mypy-django Type stubs to use the mypy static type-checker with your Django projects This project includes the PEP-484 compatible "type stubs" for Dja

Machinalis 223 Jun 17, 2022
Money fields for Django forms and models.

django-money A little Django app that uses py-moneyed to add support for Money fields in your models and forms. Django versions supported: 1.11, 2.1,

1.4k Jan 06, 2023
Create a netflix-like service using Django, React.js, & More.

Create a netflix-like service using Django. Learn advanced Django techniques to achieve amazing results like never before.

Coding For Entrepreneurs 67 Dec 08, 2022
Django-Docker - Django Installation Guide on Docker

Guía de instalación del Framework Django en Docker Introducción: Con esta guía p

Victor manuel torres 3 Dec 02, 2022
MAC address Model Field & Form Field for Django apps

django-macaddress MAC Address model and form fields for Django We use netaddr to parse and validate the MAC address. The tests aren't complete yet. Pa

49 Sep 04, 2022
Utilities for implementing a modified pre-order traversal tree in django.

django-mptt Utilities for implementing Modified Preorder Tree Traversal with your Django Models and working with trees of Model instances. Project hom

2.7k Jan 01, 2023
A simple porfolio with Django, Bootstrap and Sqlite3

Django Portofolio Example this is a basic portfolio in dark mode Installation git clone https://github.com/FaztWeb/django-portfolio-simple.git cd djan

Fazt Web 16 Sep 26, 2022
Utility for working with recurring dates in Django.

django-recurrence django-recurrence is a utility for working with recurring dates in Django. Documentation is available at https://django-recurrence.r

408 Jan 06, 2023
A simple demonstration of how a django-based website can be set up for local development with microk8s

Django with MicroK8s Start Building Your Project This project provides a Django web app running as a single node Kubernetes cluster in microk8s. It is

Noah Jacobson 19 Oct 22, 2022
Stream Framework is a Python library, which allows you to build news feed, activity streams and notification systems using Cassandra and/or Redis. The authors of Stream-Framework also provide a cloud service for feed technology:

Stream Framework Activity Streams & Newsfeeds Stream Framework is a Python library which allows you to build activity streams & newsfeeds using Cassan

Thierry Schellenbach 4.7k Jan 02, 2023
🏭 An easy-to-use implementation of Creation Methods for Django, backed by Faker.

Django-fakery An easy-to-use implementation of Creation Methods (aka Object Factory) for Django, backed by Faker. django_fakery will try to guess the

Flavio Curella 93 Oct 12, 2022
This "I P L Team Project" is developed by Prasanta Kumar Mohanty using Python with Django web framework, HTML & CSS.

I-P-L-Team-Project This "I P L Team Project" is developed by Prasanta Kumar Mohanty using Python with Django web framework, HTML & CSS. Screenshots HO

1 Dec 15, 2021
Transparently use webpack with django

Looking for maintainers This repository is unmaintained as I don't have any free time to dedicate to this effort. If you or your organisation are heav

Owais Lone 2.4k Jan 06, 2023
django-tables2 - An app for creating HTML tables

django-tables2 - An app for creating HTML tables django-tables2 simplifies the task of turning sets of data into HTML tables. It has native support fo

Jan Pieter Waagmeester 1.6k Jan 03, 2023
Extensions for using Rich with Django.

django-rich Extensions for using Rich with Django. Requirements Python 3.6 to 3.10 supported. Django 2.2 to 4.0 supported. Are your tests slow? Check

Adam Johnson 88 Dec 26, 2022
The pytest framework makes it easy to write small tests, yet scales to support complex functional testing

The pytest framework makes it easy to write small tests, yet scales to support complex functional testing for applications and libraries. An example o

pytest-dev 9.6k Jan 06, 2023
A visual indicator of what environment/system you're using in django

A visual indicator of what environment/system you're using in django

Mark Walker 4 Nov 26, 2022
A Powerful HTML white space remover for Django

HTML Whitespace remover for Django Introduction : A powerful tool to optimize Django rendered templates Why use "django_stip_whitespace" ? Adds line b

3 Jan 01, 2022
Awesome Django Blog App

Awesome-Django-Blog-App Made with love django as the backend and Bootstrap as the frontend ! i hope that can help !! Project Title Django provides mul

ANAS NABIL 2 Feb 08, 2022