Why We Use Django: Our Experience With this Python Framework

Python is one of the best and most popular programming languages on the technology market.
Thanks to its power and versatility, it can be used for a range of applications – from simple scripts, to data analysis, to machine learning (ML). Which is why in 2018, we decided to include both Python and ML in our core tech stack at Netguru. During this intense year, we have grown our Python team to 11 experienced developers and built a number of applications using the language. Some examples include:
-
A medical repository for hospitals and medical clinics that integrates medical data from different sources into one reliable system used in 44 medical institutions.
-
A health data tracking application that streamlines communication between patients and doctors.
-
A large ticketing system for a nationwide football association.
-
An ML-based outreach tool for sales reps that helps focus on closing deals instead of doing repetitive data admin.
...and more.
You can see why we love Python in general, and Django (a Python-based web framework) in particular. Read on to learn more about the reasons why we’re so enthusiastic about Django.
It’s a Python framework
This is an obvious one, but still worth mentioning. The fact that Django is built in Python means that it inherits all its strengths, such as the fact that Python code is very clean and thus easy to maintain. It’s no accident that Python is one of the most popular languages around: just check the PYPL ranking, the TIOBE Index, or this chart showing the popularity of different languages on GitHub.
It follows best practices
Django is true to the spirit of Python and follows all the best practices espoused by the language. These are:
-
KISS: keep it simple, stupid. This means that Django code naturally steers you away for unnecessary abstraction and complexity.
-
DRY: don’t repeat yourself. This boils down to keeping redundant code to a minimum, further reducing maintenance costs and complexity.
-
PEP20: the zen of Python. This is a collection of considerations worth keeping in mind when writing code, such as “explicit is better than implicit”, “simple is better than complex”, and “readability counts”.
It does a lot out of the box
Django comes with a lot of stuff already included: generic views, an admin panel, an HTML template engine, generic forms (forms can be created based on database model classes), login/logout views, and many more. This makes it easy to quickly whip up an MVP and later build it out according to the changing requirements.
It’s easy to extend
Django, just like Python, is famous for its extensibility. It’s really easy to add third-party packages to a Django app. Some of the best ones include the Django REST Framework for API creation, Redis or memcache for additional cache memory support, and Celery for async task management. No need to reinvent the wheel!
It has great documentation
Everything about Django is well-documented, and when it’s not, googling your question almost never fails. The combination of great docs and a lively community make it easy to learn about Django and troubleshoot applications written in this framework.
It uses the Model-Template-View architecture
MTV is an architectural pattern according to which parts of code responsible for different tasks (like creating the data for a view or defining the DB model) are separated, which helps maintain code. Another advantage of the MTV approach is that any Django project will have a similar structure, so a new person joining the project can easily get up to speed.
It’s secure
Security is extremely important in web applications, and Django takes it seriously. It offers features such as CSRF tokens in forms and checking user permissions before rendering the view. In addition, Django also has an automatic “before deployment” check, which will help you find any potential vulnerabilities.
It has a built-in Object Relation Manager
Django comes with a built-in ORM, which allows for easy database record management. In cases when a database query generated by Django’s ORM isn’t enough, you can use a raw SQL query and do precisely what's needed.
It scales well
Django scales well, meaning that you can use it for projects of any size. What’s even better, if your project grows to be a huge success, there’s no need to switch technologies and move away from Django. This is exemplified by such services as Pinterest, The Washington Post, or YouTube, all of which use the framework.
It works well with frontend technologies
Even though Django’s great, sometimes you need to add extra tech to your frontend stack. Luckily, that’s easy to do with our favorite Python framework – it works really well with many frontend platforms, such as Angular.
It’s battle-proven
Django has already been on the market for over 13 years, and it shows no signs of going away. This means that it’s been tested by millions of users and improved by thousands of developers. What’s even better, Django is free and open source, which ensures that the code is always kept up to date by the community. In a pinch: Django’s not going anywhere anytime soon.
It enforces a uniform coding convention
While extensive, Django is also quite opinionated: you have to do things the Django way. All Django code is (and must be) written in the same format, so there’s no additional ambiguity introduced by personal preferences. As an added bonus, a uniform coding style means that bugs are much easier to find and new devs are easier to onboard.
It’s easy to test
Django was built with support for testing in mind – it’s possible to write separate unit tests for each Django application within one project. More than that, Django can create a mock database for testing purposes, so that testing doesn’t break actual application data.
Summary
Django, a Python-based web framework, is our favorite choice for web apps for a number of reasons. It’s easy to write, extend, troubleshoot, test, and secure, making for a quick and effective development process. When an app is done, scaling it is no trouble either. Want to develop a Python app with us? Don’t hesitate to reach out – we’re always happy to talk.