2 min read

Yesterday, the team behind Django released Django 2.2 alpha 1.0. Django 2.2 is designated as LTS, which means it will receive security updates for at least three years after its expected release in April 2019. This version will come with two new constraints classes, some minor features, and deprecates Meta.ordering. It is compatible with Python 3.5, 3.6, and 3.7.

Here are some of the updates that Django 2.2 will come with:

  • Constraints: Two new constraint classes are defined in django.db.models.constraints for adding custom database constraints, namely, CheckConstraint and UniqueConstraint. These classes are also imported into django.db.models for convenience.
  • django.contrib.auth: A request argument is added to the RemoteUserBackend.configure_user() method as the first positional argument, if it accepts it.
  • django.contrib.gis: Oracle support is added for the Envelope function and SpatiaLite support for the coveredby and covers lookups.
  • django.contrib.postgres: A new ordering argument is added to the ArrayAgg and StringAgg classes for determining the ordering of aggregated elements. With new BTreeIndex, HashIndex, and SpGistIndex classes, you can now create B-Tree, hash, and SP-GiST indexes in the database.
  • Internationalization: Support and translations are added for the Armenian language.

Backward incompatible updates

Database backend API:

These are some of the changes that will be needed in third-party database backends:

  • They must support table check constraints or set DatabaseFeatures.supports_table_check_constraints to False.
  • Support for ignoring constraints or uniqueness errors while inserting is needed or you can set DatabaseFeatures.supports_ignore_conflicts to False.
  • Support for partial indexes is needed or you can set DatabaseFeatures.supports_partial_indexes to False.
  • DatabaseIntrospection.table_name_converter() and column_name_converter() are now removed. Third-party database backends will may have to implement DatabaseIntrospection.identifier_converter() instead.

Other changes

  • Admin actions: In this version, admin actions now follow standard Python inheritance and are no longer collected from the base ModelAdmin classes.
  • TransactionTestCase serialized data loading: At the end of the test, initial data migrations are now loaded in TransactionTestCase after the flush. Earlier, this data was loaded at the beginning of the test, which prevented the test –keepdb option from working properly.
  • sqlparse: The sqlparse module will be automatically installed with Django as it is now a required dependency. This change is done to simplify a few parts of Django’s database handling.
  • Permissions for proxy models: You can now create permissions for proxy models using the content type of the proxy model rather than the content type of the concrete model.

Read Next

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

Django 2.1 released with new model view permission and more

Python web development: Django vs Flask in 2018