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.
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.
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, and
receive, 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).
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.
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
- 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.
django.utils.text.unescape_entities(); use in
ungettext_lazy()are now deprecated
View the release notes for a full list of changes.