The first question people almost always ask when they’re introduced to Django is “why should I learn Django?”
“What is it about Django that makes it better than Framework X or language Y for building web applications.?”
Programming, like most creative pursuits, has many dedicated people who wear their passions on the outside.
It’s for this reason that I’m wary of This Software vs. That Software comparisons.
Bottom line is all programming languages and the tools and frameworks built on them have good points and bad points.
When it comes to comparing Django with other web frameworks It’s my firm belief that the only comparison worth considering is pragmatism vs. perfection.
Or to put it another way, do you want stable, maintainable code that you can deliver to a deadline? Or do you want a box of arcane magic and boilerplate that will simultaneously make college professors love you and maintainers hate you?
Django has its rough edges, but its pragmatic approach to getting stuff done is where it really stands out from the crowd. Django has plenty of supporters and a few haters so feel free to come to your own conclusions.
However, if you want my humble opinion, these are Django’s Top 10:
Python is arguably the easiest programming language to learn.
With its use of natural language constructs (e.g. paragraph-like layout and indentation) and simple to learn syntax, Python makes understanding program structure and flow significantly easier to learn than other popular languages.
This is evident in the fact that the greater proportion of introductory programming courses in universities and colleges now use Python as the language of choice.
Python is versatile. It runs websites and is used in many popular desktop applications on PCs and Macs. It can also be found in mobile applications and embedded in many devices. Python is also a popular scripting language for other applications.
Learning Python will almost certainly serve you no matter where your career takes you.
Python is popular. Google, one of the world’s biggest businesses, uses Python in many of its applications. It’s also used widely by professional programmers.
Some interesting facts out of the 2017 Stack Overflow Developer Survey:
Django inherits its “batteries included” philosophy from Python.
This is often interpreted as meaning that Django includes a lot of extra stuff you probably won’t need, however, the better analogy is that, instead of having to open up the language to insert your own power (batteries), you just have to flick the switch and Django does the rest.
In practical terms this means that Django implements some common, but complex processes by providing simple tools and wrappers to hide the complexity without compromising power.
Django’s “batteries” are located in the contrib packages. The contrib packages are:
The contrib packages can get a bit complex, so we will only be touching on one or two of them in this book, however as you can see, Django provides a solid list of powerful modules built-in so you don’t have to create them yourself.
When you create a Django application, Django adds no boilerplate, cruft or unnecessary functions. There are no mandatory imports, no required third-party libraries and no XML configuration files.
This can be a bit terrifying when you first create a Django project, as Django’s automatic tools (
startapp) only create a basic settings file, a few folders and some almost empty starter files.
While this might appear to be a bad thing, it’s actually a great benefit as Django has provided you with a solid foundation that you can build upon in any way you like.
The result is greater confidence in your code as you know that whatever is in your application, you put there.
Out of the box, Django provides you with an administration interface for working with your models and managing users, user permissions and groups.
The model interface immediately replaces the need for a separate database administration program for all but advanced database functions.
With very simple changes to your admin configuration, you can organize your model fields, show and hide fields, sort, filter and arrange your data to maximize your efficiency.
The admin also has an optional model documentation feature that provides automatic documentation of your models.
User management is always important in a modern website and Django provides all that you would expect—add and modify users, change passwords, create user groups, assign permissions and communicate with users.
Like the rest of Django, the admin is also customizable and extendable.
For example, admin display templates can be overridden and new functionality added for tasks like exporting your model data to a comma-delimited (CSV) file.
Django is based on the Model-View-Controller (MVC) design pattern. This means that database, program code (back-end) and display code (front-end) are separate.
These design philosophies allow you to:
Django supports a range of popular third-party vendors for web servers, performance management, caching, clustering and balancing.
It also supports major email and messaging applications and services like OAuth and ReST.
A good way to tell if any web framework is both robust and reliable is to find out how long it has been around, if it’s growing and what high-profile sites are using it.
Django was first open-sourced in 2005, after running for several years in the high demand environment of a news organization.
After nearly 12 years of growth, Django now not only runs news publishing companies like the Washington Post, but is also running all or part of major global enterprises like Pinterest, Instagram, Disqus, Bitbucket, EventBrite and Zapier.
Django continues to grow in popularity. Djangosites lists over 5200 sites using Django, and that is only for sites that register with Djangosites.
It would be impossible to guess how many pages Django serves every day compared to other technologies on the Internet, but that is largely irrelevant—Django has proven itself over the last 12 years by running some of the most heavily trafficked sites on the Internet, and continues to grow its user-base today.
Just about anything you are likely to want to do with Django has been done before.
Many of Django’s large international community of developers give back to the community by releasing their projects as open-source packages.
The largest repository of these projects can be found on the Django Packages site. At the time of writing, Django Packages lists over 3400 reusable Django apps, sites and tools to use in your own Django projects. A quick tour of popular packages includes:
With thousands more packages just like these, it’s highly likely that you will find a package that suits your needs, without having to reinvent the wheel.
One of the biggest risks of open source is whether there is sufficient interest in the project for it to attract developer support in the long term.
There is no such risk with Django—not only is the project over 12 years old, it has a long history of consistent releases and it continues to be supported by an active community and a large core team of voluntary contributors who maintain and improve the code base every day.
Django had it’s first production release in 2008 (version 1.0) and has had three Long Term Support (LTS) releases—1.4, 1.8 and 1.11. The 1.11 LTS release (current release) has full support out to the middle of 2020.
The Django development team maintains a development roadmap on the Django Project website and have a solid track record of meeting roadmap milestones.
The Django Project is also supported by an independent foundation—the Django Software Foundation—that is a registered non-profit in the US.
Open-source software projects are, in many cases, more actively developed and more secure than competing proprietary software.
The downside of the ever-evolving development of an open-source software project is the lack of a stable codebase on which to base commercial development.
Django addresses this issue with Long Term Support (LTS) versions of the software and a defined release process.
LTS versions are released with a guaranteed (typically three years) support period. In this period the codebase is guaranteed to remain stable; with patches for bugs, security and data loss 100% compatible with the feature release.
Django’s release process ensures that official releases are as stable as possible. After a development phase, each release enters an Alpha phase where a feature freeze is applied.
The new release then moves through Beta and Release Candidate (RC) stages where bugs are worked out of the release. If no major bugs are found for a period after the release candidate, the final will be released (feature release).
After the final has been released, only bugfixes and security patches are applied. These patches, like the LTS versions, are 100% compatible with the feature release.
Even in the very early releases, Django’s developers made sure that the documentation was comprehensive and that tutorials were easy to follow.
For me, the documentation should be number one on this list because it was the quality of the documentation that made me choose Django over other options.
This was in 2007 when Django was still version 0.96—before it had made its first official release. The official documentation has only got better in the intervening years.
Django also has strong support from community members who produce free learning materials, books, paid and free courses and lots of tips, tricks and assistance on their websites.
I am sure, as your Django programming career progresses, you will find your own reasons for loving how Django does things.
Of course, you are also going to discover things about Django that you find frustrating but, given every programming language and the frameworks built upon them have their idiosyncrasies, I am sure you will discover, as I have done, that when it comes to building secure and scalable websites quickly, Django’s benefits far out weight its challenges.