Python Django 3.0 is Here — Check What’s New!!

Habilelabs
Jan 8 · 7 min read

By Payal Mittal

Python Django 3.0 is Here — Check What’s New!!

“Recently, I came across an announcement on HackerNews stating that Python replaced Java as the second-most popular language on GitHub. Python has taken over the whole programming world as one of the easiest languages, that too, quite rapidly within the past 4 to 5 years only. The reason behind its popularity is its simple syntax, comprehensive standard library, application-rich & productive nature.”

Although there is a long list of Python’s features, we are not going in detail because we are here to discuss the newest version of Django, i.e. Django 3.0. It’s been a few days only and this version is already winning the developer’s hearts.

Wondering why?? Well, there is nothing to wonder about. Quality always speaks even when people fail to do so.

However, before going deep down into Django 3.0, it is important to know about Django first. If you are a beginner then you will get your basic ‘What’ and ‘Why’ questions about Django answered in this blog.

Overview About Django — Features & Benefits

Django is an open-source, high-level and free Python-based web framework, used to develop web applications and database-driven websites. It comes with all essential libraries & tools thus, often known as the “Batteries-included” framework.

One can create a web application with the use of either of any Tkinter GUI toolkit, Flask or Django framework. But which one of these will be the best fit for your project?? When to use Django?? And Why to use Django??

We can use Tkinter GUI for small projects only so, we’ll cancel out this option. Now, we’re left with two more choices, i.e. Flask or Django. As per the very first question, which one will be the best fit for your project, it depends upon your requirements. If you want to create a complex application quickly and easily then Django will be an obvious choice.

In answer to another question as ‘when to use Django’, if you want to build a secure and reliable web application with the least efforts then Django is the best choice to go for. You can also integrate your application with cutting-edge technologies like Machine Learning in the future. In the case of Flask, you will have to do most of the coding by yourself whereas Django makes it easy for you with its built-in libraries.

Major Features of Django- Why Django??

As we reach the next question, ‘why to use Django’, I would say that no framework other than Django will offer simplicity, scalability, security, flexibility and reliability to your applications. It is also rich in very intuitive technical features, such as-

  • Simple Syntax
  • Operating System Independent
  • HTTP libraries
  • Own web server
  • DRY (Don’t Repeat Yourself) Code
  • ORM (Object Relational Mapper) Support
  • Middleware Support
  • MVC (Model-View-Controller) Architecture
  • Batteries-included Framework

What’s New with Django 3.0?

As we are already aware that Django is a fast, simple and secure framework. It can be considered as an exemplary framework that allows tackling projects of any size whether it is a complex high-load web application or otherwise.

With the up-gradation of the framework, the features have also stepped a level up. Django 3.0 is compatible with the latest versions of Python, i.e. Python 3.6, 3.7 and 3.8. It enables faster database and web applications to be created, precisely and efficiently.

Now, moving aside all your assumptions, we focus our attention towards the intuitive features of Django 3.0 framework, as mentioned below-

#Supports MariaDB

Django 3.0 supports MariaDB 10.1 and higher versions with the use of MySQL backend, which is a great update. MariaDB is an open-source relational database, developed by MySQL developers, built upon three main pillars as openness, stability and performance. It is quite popular in the developers’ world due to its exclusive feature of turning data into a structured format for a number of applications.

#Python Asynch Support

Django has begun its journey being Python Asynch, one of the most powerful features of Python, which makes python programs run faster and efficiently especially in case of networking applications. In addition to the existing WSGI (Web Server Gateway Interface), Django 3.0 now provides full support to run as an ASGI (Asynchronous Server Gateway Interface) application.

For the past few years, ASGI, being a single-callable asynchronous interface, is grabbing a lot of attention, and for many good reasons. It acts as an interface between asynchronous web servers and Python asynchronous applications. While WSGI is intended to be compatible only with the synchronous web applications, it supports HTTP protocol only, which is a limitation.

But now, with the introduction of python-asynch, Django 3.0 can now run multi-queries simultaneously on a single thread.

#Enumerations for Model Field.Choices

Field Choices are now available as a group of custom enumeration types such as IntegerChoices, TextChoices, and Choices. While it is transparent from the IntegerChoices and TextChoices classes that they are indicating towards integer and text fields respectively, the Choices class enables defining enumeration for other concrete datatypes.

#Adding Exclusion Constraints on PostgreSQL

In this Django 3.0 version, support for PostgreSQL 9.4 has been dropped, rather, it now supports PostgreSQL version 9.5 or higher. The newly included feature, i.e. ExclusionConstraint class, allows adding exclusion constraints on PostgreSQL using Meta.constraints() option.

#Filter Expressions

It’s indeed a great update for the developers because unlike the previous versions, Django 3.0 can now directly use the expressions resulting BooleanField in the QuerySet filters. The same was not true earlier, in fact, previously these expressions were first annotated and then filtered against the annotations and it was quite a challenging and time-taking process.

Backwards Incompatible Changes in Django 3.0

  • Model.save(): In older versions of Django, Model.save() action used to find a row while saving a new model instance and performed either an INSERT or UPDATE based upon whether the row exists or not. But now, it only performs a single INSERT query always.

You need to call Model.save() while providing a default primary key value equivalent to pass force_insert=True to model’s save(). Any attempts to update an existing row using a new Model instance will result in IntegrityError.

  • Python 2 Private APIs: While support for Python 2 was dropped with the release of Django 2.0, some private APIs were still in use. Due to the compatibility issue, some of these APIs have been removed.
  • New default value for FILE_UPLOAD_PERMISSIONS: Previously, the setting FILE_UPLOAD_PERMISSIONS default to None but now it defaults to 0o644 to avoid the inconsistency aroused due to the default FILE_UPLOAD_HANDLERS setting.
  • New default values for Security Settings: To advance the security for Django projects, there have been enhancements in security settings. Now, SECURE_CONTENT_TYPE_NOSNIFF defaults as ‘True’ while X_FRAME_OPTIONS defaults to ‘DENY’.

Some miscellaneous changes in Django 3.0 are-

  • To disambiguate models of same names in different apps, ContentType.__st2__() includes model’s app_label.
  • To escape HTML, Django.utils.html.escape() now works as html.escape().
  • Rather than working as a shortcut for –keepdb, the django-admin test -k option now works as unittest -k.
  • The option urlencode() now encodes the iterable values, as they are when ‘doseq=False’, instead of iterating and bringing them into line with the urllib.parse.urlencode() function, as used to done earlier.
  • RegexPattern, as used by re_path(), does not return ‘None’ values keyword-arguments anymore, to be passed to the view for the optional named missing groups.

Well, this is not it, the list of all the miscellaneous changes is quite long, which you can check out in the Django 3.0 Release Notes.

Removed Features in Django 3.0

Some features have reached to the end of their deprecation cycle, thus, have been removed in Django 3.0, are as follows-

removed features from django 3.0
removed features from django 3.0
Removed Features from Django 3.0

Also,

  • Support for PostgreSQL 9.4 has been dropped, now supports versions>= 9.5.
  • Support for Oracle 12.1 ended with the release of Django 3.0, now it supports 12.2 and 18c versions.
  • Support for pywatchman versions lower than 1.2.0 is removed.
  • Support for sqlparse versions less than 0.2.2 is removed.
  • Django.contrib.gis: Django 3.0 no longer supports PostGIS 2.1, SpatiaLite 4.1, 4.2, GDAL 1.11 and GEOS 3.4.

How to Install??

Now, as we come to discuss the downloading procedure of Django 3.0, make sure to install the latest version of Python first. There are certain ways to install Django 3.0, better to go with Git Clone, as you will be notified about all the incoming changes and bugs-

git clone https://github.com/django/django.gitpython -m pip install .

You can also install it with pip command-

pip install Django==3.0.2

Well, we are done here, folks!! I hope you got all the necessary information about Django 3.0 in this blog. Django upholds being rational and contemporary and is evolving all around the world with its latest updates. It keeps upgrading to 3.0.1, 3.0.2 and so on versions, deprecating, removing outdated features and fixing all the bugs, unleashing a wide scope for future applications.

For more similar latest tech release blogs, stay tuned with our frequency!!

Technology Assets

An active Medium Publication to share insights about the latest technologies and ideas about business & start-ups.

Habilelabs

Written by

A Premium Software Development Company

Technology Assets

An active Medium Publication to share insights about the latest technologies and ideas about business & start-ups.

More From Medium

More on Web Development from Technology Assets

More on Web Development from Technology Assets

Cloud Run- Bringing Serverless to Containers

More on Python from Technology Assets

More on Python from Technology Assets

Spleeter- A TensorFlow Based Python Library

More on Web Development from Technology Assets

More on Web Development from Technology Assets

Explore New Features with Latest Next.JS 9

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade