Django 3.0 begins its async-capable journey with ASGI

Django version 3.0 is the newest version of Django. This open source Python framework was developed for fast web development tasks, with fully scalable architecture. It now begins its journey towards async-capable Django. Take a look at what the 3.0 milestone includes, what features were added and removed, and what Django has to offer Python developers.
Django, the Python web framework, released version 3.0. The newest release comes with support for MariaDB 10.1, the start of fully async-capable Django, and a few changes to default security options.
Django version 3.0 supports Python 3.6, 3.7, and 3.8.
Django benefits
Before we dive into what v3.0 introduces, here is a quick rundown of what Django offers developers.
- Speed: Its slogan is ‘The Web framework for perfectionists with deadlines‘, so it is focused on web-dev tasks made fast. Django was created with the helpful mindset of allowing devs to realize ideas as quickly as possible, with less code.
- Security: Avoid common security mistakes with its user authentication system and secure password management.
- Scalable: Meet heavy traffic demands with its “shared-nothing” architecture. Add hardware at any level, including database servers.
- Out of the box features: Without any extra downloads, Django handles user authentication, content administration, site maps, RSS feeds, and more.
Newcomers should view the repository on GitHub and read the documentation or check out the tutorials.
SEE ALSO: State of the Octoverse 2019: Python outranks Java for the first time
Async-capability
Django begins its path towards asynchronous code capability. With 3.0, it now supports running as an ASGI (Asynchronous Server Gateway Interface) application. ASGI provides an interface between asynchronous Python web servers and frameworks.
This support is in addition to support for WSGI (Web Server Gateway Interface). According to the release notes, “Django intends to support both for the foreseeable future” but asynchronous features will only be accessible by apps running under ASGI.
Follow the how-to guide if you would like to deploy with ASGI.
How does ASGI work? From the ASGI documentation:
ASGI is structured as a single, asynchronous callable. It takes
scope
, which contains details about the incoming request,send
, an awaitable that lets you send events to the client, andreceive
, an awaitable which lets you receive events from the client.This not only allows multiple incoming events and outgoing events for each application, but also allows for a background coroutine so the application can do other things (such as listening for events on an external trigger, like a Redis queue).
v3.0 changes
Other changes made in version 3.0 include a focus on added security. Now, some security settings are more secure by default. X_FRAME_OPTIONS
defaults to DENY and SECURE_CONTENT_TYPE_NOSNIFF
defaults to True.
Django now includes support for MariaDB 10.1 and up with the use of the MySQL backend. MariaDB is a popular open source relational database created by the developers of MySQL (who promise to always keep it open source). Django supports MySQL 5.6 and up.
SEE ALSO: Python tutorial: Best practices and common mistakes to avoid
Removed and deprecated features
Take note of the following changes. With 3.0, various features start their deprecation cycle. A few end their cycle and are now officially removed.
- Deprecated the
smart_text()
andforce_text()
aliases ofsmart_str()
andforce_str()
- Removed private Python 2 compatibility APIs. These APIs are all no longer in use with Python 3. Support for pywatchman < 1.2.0 and sqlparse < 0.2.2 have also been removed.
- Ended/removed support for Oracle 12.4, PostgreSQL 9.4, PostGIS 2.1, SpatiaLite 4.1 and 4.2, and GDAL 1.11 and GEOS 3.4.
- Renamed
is_safe_url()
tourl_has_allowed_host_and_scheme()
. - Deprecated
django.utils.text.unescape_entities()
; use inhtml.unescape()
instead django.utils.translation.ugettext()
,ugettext_lazy()
,ugettext_noop()
,ungettext()
, andungettext_lazy()
are now deprecated
View the release notes for a full list of changes.
Django 3.0 is NOT a LTS release. 2.2 and 1.11 were the last LTS, the next one is Django 3.2. See https://www.djangoproject.com/download/ for more information
Thank you so much for the correction Antoine! The article has been updated to reflect this.