What Is Django Used For?
October 27, 2020
For many businesses choosing a web development framework is a serious problem. There are various options on the market, each designed to address different business needs. Django is among other frameworks and is an easy choice for several reasons. Let's find out what is Django used for and why it is such a popular choice among developers and companies around the world.
- What is Django?
- What you can build with Django?
- What makes Django so powerful?
- Why use Django? - benefits of Django
- Django core features
- What companies use Django?
- Django alternatives
- Frameworks similar to Django
- For what purpose Django is used? - summary
What is Django?
Django also features an extensive ecosystem. It is one of the most popular frameworks in the world. It has a large community and most of the Python developers are familiar with it. There are many 3rd party libraries that are huge projects on it’s own like Celery for background tasks and Django Rest Framework for API. There are many smaller, but vastly used ones in many projects.
Growing such a large community was only possible thanks to Django’s official way of extending its capabilities using Django Apps.
Django is also a way of thinking. It is quite an opinionated framework. You have to do things “the Django way” or learn where and how you can extend or override it’s default capabilities. This approach is essential when you have a deadline. It gives you all you need to build a basic app or a super fast MVP development and your app will be secure and stable by default. This is a great advantage over other frameworks and many consider Django as one of the best option for such projects.
Django is ingenious. Django architecture is well designed. Its key components are delightful for the developer. Things that you have to code day and night to achieve in other frameworks can be done in minutes using the proper tool or component in Django.
Django helps Python grow. It was one of the key reasons for Python’s growing popularity.
Django is the tool for delivering MVPs fast. There are lot’s of happy clients because teams were able to deliver their projects on time and many sad clients because the teams didn’t use Django and failed to meet all deadlines.
Disclaimer - due to its popularity I am assuming that Django Rest Framework is a part of Django framework in this blog post. Probably sooner or later it will be.
What you can build with Django?
Django is used to build almost any kind of app. The larger and more business-oriented, the better. Also, with larger projects you will be able to use more key components of it.
But what kind of projects are top suited for Django?
Let me give you couple of examples from our portfolio:
- Mobile Virtual Network Operator - platform for managing users and their mobile plans subscriptions
- Ceecam - platform for managing construction site cameras and their recordings
- Upraisal - event management system
- Lendingblock - crypto exchange platform
These apps include features like:
- robust and complex notification systems via the web, mobile and mail
- ingesting large files and then serving them fast
- background post processing of large images
- business heavy back offices for help desk teams
- generating dynamic documents on the fly (like invoices, receipts etc)
- internationalisation and translations to many different languages
- countless integration with 3rd party systems, like payments, KYC etc
- exposed but secure APIs for use with mobile apps and POS-style apps
What makes Django framework so powerful?
In simple words - THE ARCHITECTURE and it comes with two core principles. Those two principles embraced by the Django Foundation team are:
- We will give you solid defaults and powerful tools to serve 90% of your use cases, fast. This means that in an average 3 months project you will be doing 90% of your features the Django way. You will feel super productive and your clients will see new features coming faster.
For example, it takes 20 lines to expose a database model as a full CRUD endpoint.
Another 5 lines to apply basic permissions to it and 50 to configure it.
This gives you a fully working, super secure API endpoint that is automatically documented using OpenAPI.
- In case of these other 10% of use cases we will design the framework so that you can easily extend it or do something more custom with it. It doesn’t mean that you have to throw away or re-write half of the web framework to achieve it. It means that Django has well defined layered architecture and you have many places to “jump in” and do something different.
For example, Views or Serializers classes give you so many official methods on many different stages of data coming to the system. You can override them, extend them to have your own code executed in a perfect place.
There are cases, however, where it is not recommended to use Django. We will cover those rare cases later in this article.
Why use Django? - benefits of Django
Django, like other web frameworks, has its own advantages and disadvantages. Both businesses and web developers must understand the benefits that Django can bring into the project.
It is extremely fast to build solid app
As we already said, rapid development is Django’s core principle. If you want to deliver fast, this is a top choice. Additionally, the more you use this web application framework, the better it gets! We had some crazy requirements (like 8 full CRUD REST endpoints) and one month deadline. Two experienced Python developers were able to deliver it on time mainly because they used Django.
Well designed architecture
Thanks to it’s well designed architecture there are many places where you can hook in and add your own custom logic. Whether it is a 3rd party Django extension that does the work for you (like adding CORS headers or uploading files to S3) or your own code. You will find it super clean to extend it in the way that no other web framework allows to.
Secure by default
Your app will be secured by default. You have to intentionally disable security features. It is a must have even if you think you have an experienced development team. Your team of developers will be always in a hurry and delivering new features will always be more important than checking the security compliance with standards.
To be honest, once we overtook a project where most of the code was custom around a low level framework. At the end of UAT we did penetration tests and discovered that JWT token implementation was wrong, resulting in session hijacking. Nobody noticed that before because there was no JWT authentication ticket, it was done behind the scenes when doing some other “super important” feature.
World class documentation
Django follows best class documentation. Every aspect of the framework is well documented. Most first class structures are documented together with their low level apis so you know exactly how things work and how deep you have to go to do your work.
That’s not all, most of google results for how to do things refers to Django documentation. This highlights how well organised the documentation is.
Super clean source code
For more proficient Django developers, there is an even better way of learning the framework - the source code. Because the source code is so elegant and well documented that it is easier and faster to jump to a specific class or function in your IDE than to search for its documentation.
Established but fresh and constantly improving
Django framework is getting quite old, having 15 years on it’s back as of today (2020). Despite that it was never so fresh. In 2012 the creation of Django Rest Framework allowed Django to jump into the modern world of API based apps with ease! In 2014 with Django 1.7 we got the best DB schema migration system that you can find. In 2017 with version 2.0, Django broke compatibility with Python 2 and cleaned it’s code base to prepare for a large dosage of new features. New features like ones you can find in Django 3.1 (released just now, 2020): support for async views, middlewares and tests.
Django core features
Best in class ORM
There is simple no better ORM. It’s expressiveness is legendary. I will give you just one example:
Gives you active users with an active subscription plan. Would you like to try to write it with other ORMs? like SQLAlchemy:
Best in class toolkit for building REST apis
I am talking about Django Rest Framework. With just 8 lines of code, you have full CRUD as a REST api exposed to the outside world.
Would you like to add authentication, authorization, more gradual permission, more custom serialization, some background jobs on object creation? All these and more you can do within just minutes of your work.
Best in class background task execution
Celery is a Python library that has a quite established place in the whole Python ecosystem. Although not a Django specific library, Celery is highly integrated with Django. Because of that no hacking around is needed, they just work together flawlessly. Celery is a mature library that gives you an interface that will suit your school side project as well as Instagram’s robust image processing infrastructure. Impressive is it?
Best in class mini CMS
Remember the one month project? Django framework gives you a configurable Admin interface to manage your database models. It is not suited for larger or long term projects but it saved our client project. Often we start with that for the prototype and even some MVPs. Why spend 2 sprints building a simple back office if you can have one in a day?
That just works out of the box. Hook it with [pytests] and you will never have to fight with a testing environment.
- Cleaning db objects after each test? - done.
- Fast test execution? - done.
- Auto authenticate users bypassing auth layer? - done.
It is pain free testing. You won’t be able to find similar solutions in other frameworks and you will have to spend your precious time fighting with them. Django takes care of it faultlessly.
Asynchronous views and middlewares
Support for async work finally arrived in Django 3.0 and 3.1. And with it yet another reason against Django has disappeared. Now you can finally build websockets integration and apps like chats or bots.
What companies use Django?
It is used by many big players nowadays. Not only that, we think the reasons those companies were able to grow so big is precisely due to Django: when their competition was reinventing the wheel, they just shipped feature after feature.
In 2017, they announced that they finished upgrading their stack to Python 3. In other announcements they elaborated that they use Django + Celery as core components.
Blog comment hosting service serving more than 8 billion page views per day in 2013! They introduced their Django optimization solution in this blog post.
Sentry is an error monitoring system as a service, founded by famous Python developer David Cramer and Armin Ronacher (creator of Flask) as a Director of Engineering. What is interesting about Sentry is that it is open sourced, you can check the code here and it uses Django.
Well known event management system. In their blog post they described how they moved from custom framework to Django.
Paul Sciarra, the co-founder, answered in quora that Django is their main framework for the application layer. In that article (from 2012), having 14 employees they were serving 18 million visitors using 150 EC2 instances for their web app.
After shipping a couple of Django projects, you are likely to not want to change it to any other Python. Nevertheless, in the Python world we have many alternatives but most of them have similar features.
You can think about Flask as the most popular framework after Django. Its' popularity came from really good documentation and simple usage. We think that Flask could be a good choice as a toy framework for a school project but using it is getting more and more difficult as the project size grows. We have even written an article Is Flask good for your application? But if you want to compare Flask vs Django - we have covered that too.
If all you need is a low level framework, Pyramid is a way to go. As said in their documentation, it is a “framework framework” - a way to craft your own special-purpose domain-specific web system.
When not to use Django?
The heart of Django lies in its ORM and ORM works only with SQL databases.
So not using SQL databases is a really good argument against using Django.
If you are using a multitude of very complex SQL queries, (and I do mean really complex queries) then it could be worth considering using another framework like Pyramid with SQLAlchemy as ORM.
If you are building chat alike apps, then it is worth considering FastAPI and a backend of choice due to its asynchronous nature.
That’s it. Nothing more. I would be really happy if you could comment down below if you have other pushbacks.
Frameworks similar to Django
We think Django is a top-notch framework and probably one of the best in the world.
Other languages have their own heros, we asked other devs about their choices, this is what we get.
Ruby has Ruby on Rails
We should give lots of Kudos to RoR and it’s founder David Heinemeier Hansson (aka DHH) because he was the first one to popularize Active Record pattern.
As far as I heard, it is an awesome framework and quite similar to Django. Recently DHH announced their new product hey.com (2020) which is a new email client that was built on top of RoR.
The dawnside on betting on Ruby on Rails is fading away popularity of Ruby language.
PHP has Laravel
Robust PHP framework that has huge popularity among PHP developers. It has a similar philosophy to Django - batteries included. I could even tell that it is a much larger and more opinionated framework than Django just by glancing at their ecosystem spec.
There is a similar downside on betting on Laravel as for Ruby on Rails - it’s fading away popularity. Moreover PHP has a bad reputation as a badly designed language in its core. Nicely summarized here and here and here and here. Also it is harder to find a PHP developer who would say he loves PHP.
Java/Kotlin has Spring
Java programming language was always a solid enterprise language for both mobile and web applications. Kotlin is its natural successor - most of Java devs are currently transitioning to Kotlin. Google recently switched to Kotlin as a default language for Android applications.
Spring framework is a logical choice when it comes to web application development in Java/Kotlin. I have never heard of a Java web developer who is not using Sprint as a go-to framework for web development.
C# has .NET Core
We have heard only positive opinions about .Net Core and C#. Although more enterprise oriented it is a really well designed platform, framework and language.
Microsoft did amazing job designing C# and it’s ecosystem - lot’s of Java folks are quite envious when they taste it and have to come back to the Java world.
For what purpose Django is used? - summary
If you would like to develop a web or mobile app but have doubts about the framework you should choose - you should consider Django. It’s a powerful, Python-based framework, commonly used by developers to deliver web applications as well as mobile projects.
At Ulam Labs we have best class Python and Django developers. Drop us a line if you are thinking about developing your own digital product. We will help you choose the best framework for your needs.