Django 3.0 release, began to support asynchronous function

Django 3.0 release, this version brings some new features, the most notable of which should be started to support asynchronous functionality.

Previously, we reported, the draft proposes to make Django supports asynchronous . Gathered to view HTTP middleware and ORM, developers want to add asynchronous support in Django, while maintaining support for synchronization of Python, and is fully backward compatible.

The vision will eventually replace most of the blocking part of Django, including Session, Auth, ORM and Handlers, etc., to native support for asynchronous . The synchronous API will continue to exist and are fully supported, some of which eventually will be converted to synchronous wrapper native asynchronous code.

ASGI Django model will run as a native asynchronous applications, the original WSGI model will run around calling each Django single event loop, so that asynchronous processing layer is compatible with the synchronization server.

In this transformation process, each property will undergo the following three implementation phases:

  • Sync-only, only supports synchronous, which is the current situation
  • Sync-native, native synchronization, while with the asynchronous wrapper
  • Async-native, native asynchronous to synchronous belt wrapper

Django 3.0 start running ASGI provide application support, so Django has gradually asynchronous function. After doing this change, Django now perceived asynchronous event loop, and will prevent the context from asynchronous calls marked as "asynchronous unsafe" code (for example, operating ORM), if previously used developer is asynchronous code, you may It will be triggered. If you see SynchronousOnlyOperation errors, you can double-check code and database operations to a synchronous sub-thread.

Other aspects, Django now supports MariaDB 10.1 and later; ExclusionConstraint class can add new exclusion restrictions on PostgreSQL; BooleanField output expression can now be used directly in the QuerySet filter, without having to first comment on the notes and then filtered; custom enumerated type TextChoices, IntegerChoices Choices and method can now be used to define Field.choices.

There are also some minor changes, details View update:

Note that, Django 3.0 support Python 3.6,3.7 and 3.8, Django 2.2.x series is the last to support Python 3.5 series. The official also suggested third-party application authors to abandon support for all versions prior to 2.2 Django.

Guess you like

Origin www.oschina.net/news/109798/django-3-0-released