News

Django 2.2 is now out with classes for custom database constraints

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

Bhagyashree R

Share
Published by
Bhagyashree R

Recent Posts

Harnessing Tech for Good to Drive Environmental Impact

At Packt, we are always on the lookout for innovative startups that are not only…

2 months ago

Top life hacks for prepping for your IT certification exam

I remember deciding to pursue my first IT certification, the CompTIA A+. I had signed…

3 years ago

Learn Transformers for Natural Language Processing with Denis Rothman

Key takeaways The transformer architecture has proved to be revolutionary in outperforming the classical RNN…

3 years ago

Learning Essential Linux Commands for Navigating the Shell Effectively

Once we learn how to deploy an Ubuntu server, how to manage users, and how…

3 years ago

Clean Coding in Python with Mariano Anaya

Key-takeaways:   Clean code isn’t just a nice thing to have or a luxury in software projects; it's a necessity. If we…

3 years ago

Exploring Forms in Angular – types, benefits and differences   

While developing a web application, or setting dynamic pages and meta tags we need to deal with…

3 years ago