Stable Release in branch 2.2 (LTS)
2.2.28
Released 11 Apr 2022
(4 years ago)
SoftwareDjango
Version2.2 (LTS)
StatusLTS
End of life
Supported
Python versions
Python 3.5 - 3.9
Initial release2.2
01 Apr 2019
(7 years ago)
Latest release2.2.28
11 Apr 2022
(4 years ago)
End of
mainstream support
02 Dec 2019
(Ended 6 years ago)
End of
extended support
11 Apr 2022
(Ended 4 years ago)
Release noteshttps://docs.djangoproject.com/en/2.2/releases/
Source codehttps://github.com/django/django/tree/2.2.28
Documentationhttps://docs.djangoproject.com/en/2.2/
Django 2.2 (LTS) ReleasesView full list

What Is New in Django 2.2

Django 2.2 is a Long Term Support (LTS) release, bringing stability and several key enhancements. This version focuses on database constraints, improved admin interfaces, and various developer experience refinements.

Category Key Changes
New Features Database-level constraints, CheckConstraint & UniqueConstraint, admin site customization classes
Improvements Faster model saving, bulk_update(), HttpResponse improvements, admin search updates
Backend Support MariaDB recognition, Oracle 12c+ identity columns, MySQL 8+ support
Deprecations django.utils.timezone.FixedOffset, django.contrib.postgres.fields.JSONField

How does Django 2.2 improve database constraints?

This release introduces a powerful new API for defining database constraints directly from your models. You can now use CheckConstraint and UniqueConstraint classes within your model's Meta.constraints option.

In practice, this means your validation logic moves closer to the database, ensuring data integrity even if other applications access the same database. You can define complex constraints that were previously difficult to enforce at the ORM level.

from django.db import models

class Customer(models.Model):
    age = models.IntegerField()
    status = models.CharField(max_length=10)

    class Meta:
        constraints = [
            models.CheckConstraint(check=models.Q(age__gte=18), name='age_gte_18'),
            models.UniqueConstraint(fields=['status', 'age'], name='unique_status_age')
        ]

What admin customization features were added?

Django 2.2 makes the admin site more customizable through class-based configuration. The new AdminSite class allows you to override default behaviors like site headers, titles, and URLs without monkey-patching.

You can now create multiple admin site instances with different configurations, which is useful for complex projects requiring separate admin interfaces. This approach is cleaner than the previous function-based customization methods.

from django.contrib.admin import AdminSite

class CustomAdminSite(AdminSite):
    site_header = 'Custom Administration'
    site_title = 'Custom Admin Portal'
    index_title = 'Welcome to the custom admin'

custom_admin_site = CustomAdminSite(name='custom_admin')

What performance improvements should I know about?

The bulk_update() method was added, allowing you to update multiple model instances with a single query. This significantly reduces database round-trips when you need to update many objects at once.

Model saving operations became faster through optimized SQL generation. The ORM now generates more efficient INSERT and UPDATE statements, particularly noticeable when working with large datasets.

# Update multiple objects efficiently
objects_to_update = [obj1, obj2, obj3]
for obj in objects_to_update:
    obj.field = new_value

Model.objects.bulk_update(objects_to_update, ['field'])

How does HTTP response handling improve?

HttpResponse now supports context manager protocol for proper resource handling. You can use HttpResponse objects in with statements, ensuring that resources are closed properly even if exceptions occur during response processing.

The new HttpResponse.headers attribute provides a case-insensitive interface for accessing response headers. This simplifies header manipulation compared to the previous dictionary-like access.

# Using HttpResponse as context manager
with HttpResponse() as response:
    response.write('Hello')
    response.headers['X-Custom-Header'] = 'Value'
    return response

FAQ

Is Django 2.2 an LTS release?
Yes, Django 2.2 is a Long Term Support release. This means it will receive security updates and data loss fixes for an extended period, typically three years, making it suitable for production environments that require stability.

What database backends are officially supported?
Django 2.2 supports PostgreSQL, MySQL, MariaDB, SQLite, and Oracle. Notably, MariaDB is now properly recognized as a distinct database backend rather than being treated as MySQL.

Should I replace my existing JSONField imports?
Yes, you should migrate from django.contrib.postgres.fields.JSONField to django.db.models.JSONField. The old import path was deprecated in 2.2 and removed in later versions.

How does bulk_update() differ from update()?
While update() performs a single query to update multiple rows with the same values, bulk_update() allows updating different instances with different values in a single query, making it more flexible for varied updates.

What Python versions are compatible?
Django 2.2 requires Python 3.5, 3.6, or 3.7. Python 3.4 support was dropped in this release, so you'll need to upgrade your Python environment if you're still using older versions.

Releases In Branch 2.2 (LTS)

VersionRelease date
2.2.2811 Apr 2022
(4 years ago)
2.2.2701 Feb 2022
(4 years ago)
2.2.2604 Jan 2022
(4 years ago)
2.2.2507 Dec 2021
(4 years ago)
2.2.2402 Jun 2021
(5 years ago)
2.2.2313 May 2021
(5 years ago)
2.2.2206 May 2021
(5 years ago)
2.2.2104 May 2021
(5 years ago)
2.2.2006 Apr 2021
(5 years ago)
2.2.1919 Feb 2021
(5 years ago)
2.2.1801 Feb 2021
(5 years ago)
2.2.1702 Nov 2020
(5 years ago)
2.2.1601 Sep 2020
(5 years ago)
2.2.1503 Aug 2020
(6 years ago)
2.2.1401 Jul 2020
(6 years ago)
2.2.1303 Jun 2020
(6 years ago)
2.2.1201 Apr 2020
(6 years ago)
2.2.1104 Mar 2020
(6 years ago)
2.2.1003 Feb 2020
(6 years ago)
2.2.918 Dec 2019
(6 years ago)
2.2.802 Dec 2019
(6 years ago)
2.2.704 Nov 2019
(6 years ago)
2.2.601 Oct 2019
(6 years ago)
2.2.502 Sep 2019
(6 years ago)
2.2.401 Aug 2019
(7 years ago)
2.2.301 Jul 2019
(7 years ago)
2.2.203 Jun 2019
(7 years ago)
2.2.101 May 2019
(7 years ago)
2.201 Apr 2019
(7 years ago)
2.2rc118 Mar 2019
(7 years ago)
2.2b111 Feb 2019
(7 years ago)
2.2a117 Jan 2019
(7 years ago)