Reviewing Django asynchronous support
The long journey to support for asynchronous programming in Django started in version 3.0, released at the end of 2019. The first approach was the previously mentioned asgiref adapter, which allowed WSGI applications to be deployed in ASGI servers. This is one of the most important modules because it brings the sync_to_async (https://docs.djangoproject.com/en/5.1/topics/async/#asgiref.sync.sync_to_async) function/decorator, which lets you wrap a synchronous piece of code into an asynchronous function that can be run in the same main execution thread as the main request or in a separate thread context.
There have been many other improvements to the Django ecosystem’s asynchronous support, the following diagram showing a timeline of the principal asynchronous features released per version:
Figure 7.5: Django async support evolution
The basic concepts we have described for Flask apply to Django, so if for example you deploy...