Django é a estrutura da Web para perfeccionistas?

Is Django the Web Framework for Perfectionists?

Django is the leading python-based web framework, with a friendly community and hundreds of libraries, it is one of the best options for developers with high demands and tight deadlines.

Desenvolvimento de software Django

When I give my coding seminars to undergraduates, I like to start with a game. First, I ask them to explain a concept (like “web frameworks”). The first person to get it right gets a small reward. As you'd expect, after I signal, dozens of faces sink into their phones, tablets, and laptops searching for the answer on Google. We usually get a winner after a few minutes.

Then I ask my students to put all of their devices on airplane mode and do a second round with a different concept. Obviously, without fast internet access, they are forced to go out and look for internet access. On average, it takes about 10 to 15 minutes to get a response.

Finally, we went for a third round, another concept, but this time without using the internet. Of course, this means searching the library, which takes 30 minutes or more.

After the rewards were handed out, we talked a little about the experiment. Most students think I'm trying to show them that things were much more difficult when Internet access was restricted or nonexistent, and yes, there is truth to that, but the point I'm trying to make is a matter of time.

The way we measure time hasn't changed over a few hundred years, but the way we experience time has. It seems like every day the world moves a little faster and seconds are more valuable than ever. We work faster, we consume faster, we move faster. Like an experienced chef, we surgically eliminate unnecessary and time-consuming activities so that we can have a more productive and quality time.

Let's stick with this metaphor for a minute. If we are chefs and our dish is a web application, then a web framework is the skinning knife. By automating the most tedious and time-consuming activities of web development, we reduce overhead, make better dishes, and get them to the table faster.

For perfectionists like me, relying on standardized libraries and templates for a web framework may seem wrong. There's always a little voice in the back of your head telling you that you're cheating or that you could do a better job if you did everything from scratch.

And there's a ring of truth to that, but on the other hand, a custom build requires time and resources that you might not have. Therefore, if you opt for a web framework, you will need a reliable technology that you can trust, that is customizable enough that you can add your personal touch without sacrificing the benefits of automated processes.

For me, when I have to develop database-based websites, this web framework is Django

What is Django?

Django is an open source web framework developed entirely in Python by Adrian Holovaty and Simon Willison, and named after legendary jazz guitarist Django Reinhardt. The framework was developed organically in 2003, when the authors made the jump from PHP to Python.

After tweaking the framework for a few years, the company World Online decided to release the framework under a 3-clause BSD license in 2005. Then in 2008, the non-profit organization Django Software Foundation (DSF) was created to maintain Django. and promote its use. This makes Django 15 years old at the time of writing this article.

A pretty venerable web framework by any standard, thanks to DSF and a huge, active community, the framework continues to receive regular updates.

Why use Django?

Because it's done in Python! Jokes aside, Python is not only the most popular language on the market today, but it is also very easy to learn, read, and maintain properties that Django has inherited in one way or another.

We can see this in action in two of Django's core principles: component reuse and the “don't repeat yourself” philosophy. Django promotes using as little code as possible and reusing assets to minimize the time between design and deployment.

Don't like how Django does something? In most cases, you can customize it with Python. For example, if you are not satisfied with the administrative interface, you can replace it with a few lines of code.

Of course, the same could be said of other Python-based frameworks like Flask, but there are more reasons why Django is so good:

  • Friendly community and extensive libraries: Because Django has a reputation for being the springboard for new web developers, the community around it has a reputation for being one of the friendliest out there. As such, Django users have access to a multitude of packages for their work, including the Django REST framework (for building APIs) and the Django CMS for managing website content.
  • Out-of-the-box solutions: Django comes with many easy-to-configure solutions, like an object-relational mapper so you can describe your database layout in Python or a fully-featured administrative interface that provides a model-centric interface that's a breeze to use.
  • Strong security: Django's security tools allow developers to protect their projects against cyberattacks. These tools include cross-site scripting, cross-site request forgery, and SQL injection. Additionally, using a web framework is another layer of protection, as you rely on code that has been validated by a community, avoiding potential security risks created by Python coding.
  • It's mature: With over a decade of experience, Django has undergone numerous revisions and has been used for all types of web applications, such as online stores, news sites, and even social media. Whatever your project, there's likely a tutorial, documentation, or Stack Overflow thread you can check out for inspiration.

So what's the trick?

No web framework is perfect, and even Django has many problems that a perfectionist must understand before using it:

  • Slow performance for small applications: Django is a huge and powerful framework that was originally designed for developing complex web projects. As such, all the features that come with it can negatively impact very small applications that would run at a fast pace with less intensive frameworks like Flask.
  • No multiple requests: More modern frameworks improve the performance of a web application by allowing each process to handle multiple requests. Unfortunately, Django was created before this was the norm. As such, a developer will have to hack ways for individual processes to handle multiple requests (or brute-force a solution)
  • It's tightly coupled: Although Django sells itself as a loosely coupled solution, this was true over a decade ago, but not anymore. Other structures allow for more loosely coupled components in comparison.

What is the final verdict?

Within its limitations, Django is one of, if not the most popular and robust Python web framework available (although JavaScript and PHP developers still lead the pack). By all standards, it's a powerful, streamlined tool that delivers exactly what it promises out of the box.

For smaller projects, you may be better off using Flask as an alternative. Most Python developers have no problem knowing both frameworks and choosing the best one depending on the size and scope of the project.

For developers who want a high-quality product with tight deadlines, Django is a powerful, scalable, customizable framework that has one of the most versatile languages ​​on the market.

If you liked this, be sure to check out our other articles on React.

  • What can a good Python developer do to help your company?
  • How to hire a Python programmer
  • Is Python good for software development?
  • JavaScript vs Python: A Comparison and How to Choose
  • Top 9 Python Libraries for Machine Learning

Source: BairesDev

Back to blog

Leave a comment

Please note, comments need to be approved before they are published.