What’s new in Django 3.0

On December 2, 2019, the Django Team announced the release of the latest version of Django. There is no doubt Django 3.0 is here to stay but, what are the new features included in this version? In this article, we’ll list some of our highlights.

Welcome, MariaDB!

MariaDB is a free and open-source relational database, developed by some of MySQL’s original developers. With Django’s latest release, you can now use MariaDB 10.1 and higher.

MariaDB Logo - Django 3.0

How can I connect MariaDB to my Django 3.0 web application? 

This is done in the same way you connect to a MySQL database as they both share the same backend connector:

ASGI support

Django 3.0 is now fully async-capable, it provides support for running as an ASGI application in addition to the existing WSGI support.

ASGI (Asynchronous Server Gateway Interface) is a spiritual successor of WSGI, intended to provide a standard interface between async-capable Python web servers, frameworks and applications.

WSGI succeeded in providing much more freedom and innovation in the Python webspace and ASGI’s goal is to continue this onward into the land of asynchronous Python.

Python Logo

How does ASGI work?

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 that lets you receive events from the client.

In its simplest form, an application can be written as a function as follows:

How do I deploy my Django 3.0 web application with ASGI?

Django’s startproject management command sets up a default ASGI configuration that you can then tweak as needed for your project, and direct any ASGI-compliant application server to use.

If you want to apply ASGI middleware, or embed Django in another ASGI application, you can just wrap Django’s application object in the asgi.py file, as you can see below:

Why should I upgrade an existing project to the latest version of Django?

Although it can sometimes be a complex process, upgrading to the latest Django version has the following benefits:

  • The new version includes new features and improvements.
  • It has also fixed existing bugs.
  • The older version of Django will eventually stop receiving security updates. 
  • If you stay up-to-date with each new Django release as it’s made available, future upgrades will be less painful.

Up next, we’ll share some aspects to consider to help make your upgrade process as smooth as possible.

Required Reading

If this is the first time you upgrade, we advise you to read Django’s guide on the different release processes. 

After that, take a close look at the changes that were made in the new Django version(s):

  • Make sure you read the release notes for the version released after your current Django version, all the way up to the version to which you plan to upgrade.
  • Take a look at the deprecation timeline for the relevant versions.

You should pay special attention to backward-incompatible changes to get a good idea of what will be needed for a successful upgrade.

Django 3.0

Django 3.0 installation

Once you’ve finished all your reading, it’s time to install the new Django version. If you are using virtualenv and are dealing with a major upgrade, it might be advisable to first set up a new environment with all the necessary dependencies.

If you’ve installed Django with pip, you can use the –upgrade or -U flag:

$ python -m pip install -U Django

Django 3.0 final thoughts

If your project is working in MariaDB, or you are interested in migrating, it could be worth your while to upgrade your version of Django to take advantage of the official support. In the same way, if your project has some async functionalities, or if it’s completely async, you can now use Django 3.0 without substantial complications.