Django 4.1 adds asynchronous handlers
Django 4.1, a new version of the leading Python-based web framework, adds features such as asynchronous handlers and an ORM interface, but also brings changes incompatible with earlier versions.
Unveiled on August 3, Django 4.1 can be accessed from the Django Project website. The new version introduces asynchronous handlers for class-based views; show subclasses can now define asynchronous HTTP method handlers, according to the 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 the need to write ORM operations in
sync_to_async(). At this point, the underlying database operations remain in sync.
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:
exclusionconstraints defined in the
Meta.constraintsoption are now checked when validating the model.
- New Form templates based on are available to help users who have screen readers and other assistive technologies.
CSRF_COOKIE_MASKEDThe transition setting allows developers to specify whether to hide the CSRF (Cross Site Request Forgery) cookie.
SECRET_KEY_FALLBACKSThe parameter allows to provide a list of values for the validation of the secret key.
- For templates, HTML
idattribute is no longer required when encapsulating the
- For the test, the
DiscoverRunnernow supports running tests in parallel on Windows, macOS and any other system where the default
multiprocessingthe start method is
A number of backwards incompatible changes have been made, some of which impact the core database API. The release notes detail specific changes such as
BaseDatabaseFeatures.has_case_insensitive_likebeing changed from
Falseto reflect the behavior of most databases.
PostgreSQL 10 upstream support ends in November. Django 4.1 supports PostgreSQL 11 and above. Additionally, support for MariaDB 10.2 ended in May, so Django 4.1 supports MariaDB 10.3 and later.
In another change, to unify behavior with many-to-many relationships for unregistered model instances, a reverse foreign key now throws a ValueError when calling related handlers for unregistered objects.
Copyright © 2022 IDG Communications, Inc.