2 min read

Yesterday, the Django team announced the release of Django 2.2. This release comes with classes for custom database constraints, Watchman compatibility for runserver, and more. It comes with support for Python 3.5, 3.6, and 3.7.

As this version is a long-term support (LTS) release it will receive security and data loss updates for at least the next three years. Also, this release marks the end of the mainstream support for Django 2.1 and it will continue to receive security and data loss fixes until December 2019.

Following are some of the updates Django 2.2 comes with:

Classes for custom database constraints

Two new classes are introduced to create custom database constraints:

CheckConstraint and UniqueConstraint. You can add constraints to the models using the ‘Meta.constraints’ option.

Watchman compatibility for runserver

This release comes with Watchman compatibility for runserver replacing Pyinotify. Watchman is a service used to watch files and record when they change and also trigger actions when matching files change.

Simple access to request headers

Django 2.2 comes with HttpRequest.headers to allow simple access to a request’s headers. It provides a case insensitive, dict-like object for accessing all HTTP-prefixed headers from the request. Each header name is stylized with title-casing when it is displayed, for example, User-Agent.

Deserialization using natural keys and forward references

To perform deserialization you can now use natural keys containing forward references by passing ‘handle_forward_references=True’ to ‘serializers.deserialize()’. In addition to this, forward references are automatically handled by ‘loaddata’.

Some backward incompatible changes and deprecations

  • Starting from this release, admin actions are not collected from base ModelAdmin classes.
  • Support is dropped for Geospatial Data Abstraction Library (GDAL) 1.9 and 1.10.
  • Now, the team has made sqlparse a required dependency to simplify Django’s database handling.
  • Permissions for proxy models are now created using the content type of the proxy model.
  • With this release, model Meta.ordering will not affect GROUP By queries such as  .annotate().values(). Now, a deprecation warning will be shown with the advice to add an order_by() to retain the current query.

To read the entire list of updates, visit Django’s official website.

Read Next

Django 2.2 alpha 1.0 is now out with constraints classes, and more!

Django is revamping its governance model, plans to dissolve Django Core team

Django 2.1.2 fixes major security flaw that reveals password hash to “view only” admin users