DEV Community

Priyanshu Panwar
Priyanshu Panwar

Posted on

Django 2.x V/S Django 3.x

In this article, we'll talk about the new features added to Django 3.x and their differences, though Django 2.2.x still has a Long Term Support. (I still use Django 2.2.6)
Before we start, Both Django versions work very well with Python 3.x, though one might feel some problem with some libraries in Django 2.x for python 3.6+(in rare libraries).

New Features added in Django 3.x

MARIA DB

Django 3.x comes in support with Maria DB. This might not effect most of the django programmers but for those who are fans of this open source MYSQL database.
This is how you can use MariaDB in your django project.

# settings.py
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'OPTIONS': {
            'read_default_file': '/path/to/my.cnf',
        },
    }
}
Enter fullscreen mode Exit fullscreen mode
# my.cnf
[client]
database = NAME
user = USER
password = PASSWORD
default-character-set = utf8
Enter fullscreen mode Exit fullscreen mode

ASGI in Django - Biggest Upgrade of 3.x

  • 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. Let's take a simple example to see the working of async python in django.
async def application(scope, receive, send):
    event = await receive()
    ...
    await send({"type": "websocket.send", ...})
Enter fullscreen mode Exit fullscreen mode

These two features are the main upgrades in the Django 3.0
If you are looking to work with MariaDB or want to use the power of async python, then definitely upgrade to Django 3.0

THANK YOU

Feel Free to ask me anything in comments or reach out to me directly. Priyanshu Panwar | LinkedIn

Top comments (0)