Select the directory option from the above "Directory" header!

Menu
Django 4.1 adds async handlers

Django 4.1 adds async handlers

Latest version of the popular Python web framework also provides an asynchronous interface for all data access operations.

Credit: Dreamstime

Django 4.1, a new version of the major Python-based web framework, adds capabilities such as asynchronous handlers and an ORM interface but also makes some backward-incompatible changes.

Unveiled August 3, Django 4.1 can be accessed from the Django project website. The new release introduces asynchronous handlers for class-based views; view subclasses now may define async HTTP method handlers, according to release notes.

For asynchronous object-relational mapping, QuerySet now provides an asynchronous interface for all data access operations. The new interface allows developers to write asynchronous code without needing to write ORM operations in sync_to_async(). At this stage, underlying database operations remain synchronous.

Django 4.1 supports Python 3.8, Python 3.9, and Python 3.10, but only the latest version of each series. Also in Django 4.1:

  • Check, unique, and exclusion constraints defined in the Meta.constraints option now are checked during model validation.
  • New <div>-based form templates are available, to aid users who have screen readers and other assistive technology.
  • A CSRF_COOKIE_MASKED transitional setting allows developers to specify whether to mask the CSRF (Cross Site Request Forgery) cookie.
  • A SECRET_KEY_FALLBACKS setting allows for providing a list of values for secret key validation.
  • For templates, the HTML <script> element's id attribute is no longer required when wrapping the json_script template.
  • For testing, the DiscoverRunner now supports running tests in parallel on Windows, macOS, and any other systems where the default multiprocessing start method is spawn.

A number of backward-incompatible changes were made, including some impacting the database back-end API. Release notes detail specific changes such as BaseDatabaseFeatures.has_case_insensitive_like being changed from True to False to reflect the behaviour of most databases.

Upstream support for PostgreSQL 10 ends in November. Django 4.1 supports PostgreSQL 11 and higher. Additionally, with support for MariaDB 10.2 having ended in May, Django 4.1 supports MariaDB 10.3 and higher.

In another change, in order to unify the behaviour with many-to-many relations for unsaved model instances, a reverse foreign key now raises a ValueError when calling related managers for unsaved objects.


Follow Us

Join the newsletter!

Or

Sign up to gain exclusive access to email subscriptions, event invitations, competitions, giveaways, and much more.

Membership is free, and your security and privacy remain protected. View our privacy policy before signing up.

Error: Please check your email address.

Tags python

Show Comments