days
0
-11
0
hours
-1
0
minutes
-3
-6
seconds
-4
-6
search
The Python framework gets an upgrade

Django 3.0 begins its async-capable journey with ASGI

Sarah Schlothauer
django
© Shutterstock / Isaeva Studio

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, 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).

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() and force_text() aliases of smart_str() and force_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() to url_has_allowed_host_and_scheme().
  • Deprecated django.utils.text.unescape_entities() ; use in html.unescape()instead
  • django.utils.translation.ugettext()ugettext_lazy()ugettext_noop()ungettext(), and ungettext_lazy() are now deprecated

View the release notes for a full list of changes.

Author
Sarah Schlothauer

Sarah Schlothauer

All Posts by Sarah Schlothauer

Sarah Schlothauer is an assistant editor for JAXenter.com. She received her Bachelor's degree from Monmouth University and is currently enrolled at Goethe University in Frankfurt, Germany where she is working on her Masters. She lives in Frankfurt with her husband and cat. She is also the editor for Conditio Humana, an online magazine about ethics, AI, and technology.

Leave a Reply

2 Comments on "Django 3.0 begins its async-capable journey with ASGI"

Antoine Lorence
Guest

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