DEV Community

Salvietta150x40
Salvietta150x40

Posted on • Originally published at ma-no.org

What Is Django and What Is It Used For

What Is Django and What Is It Used For

An high-level Python Web framework that encourages rapid development and clean design

When we talk about Django, we refer to that framework that is used for any totally free and open source web application which is written in Python. Basically, it's a group of elements that will help you create web pages much more easily and quickly.

At the moment you are going to make a web page, you usually require several similar elements: a way to control all authentication by users such as their (registration, login, completion), the panel to manage the web page, the various forms, the ability to upload a document or file, etc.

There are several guys who realized that every web developer faces similar issues when making a site. That's why they have joined forces and developed frameworks (Django being part of one of these) which will provide you with the elements to build your website.

These framworks are there to speed up the web creation process and not to have to reinvent the wheel in general. That way, you will get support by relieving the weight when creating the web.

Why do I need a framework?

If you want to understand what Django is all about, you need to look a little closer at each server. The main thing is that a server needs to know what you want to make a website useful.

Let's imagine we have a mailbox where this would be the port. This is constantly monitored by letters that would come as requests. This is done by a web server. The moment you want to send something, you must load it with the appropriate content. Django is in charge of helping you create the content.

What's Django?

Django (gdh/ˈdʒæŋɡoʊ/jang-goh) is a free, open source web application framework written in Python. A web framework is a set of components that help you develop websites more easily and quickly.

What happens when someone requests a website from your server?

When a request arrives at the server, it is sent to Django. What he will try to do is find out what is really being requested. First you have to get the address of the site and try to find out how to proceed.

At this point, Django's urlresolver is in charge of solving it (keep in mind that the address of a page is designated as URL - Uniform Resource Locator), so urlresolver makes sense.

The truth is that we are talking about a function that is not so smart as it tries to look for patterns to find the URL. Django manages to corroborate each pattern from top to bottom and when it finds a match, Django passes each request to the function that is linked and called "view".

You can get an idea if you put a postman carrying a message or letter into context. He is walking around and seeks to corroborate each room or house number with that of the letter he is carrying. If there's a turnout, he leaves the message there - it works the same way url resolve!

With the view function there are several things to consider: you can look inside the database in order to find some information. Is it possible that someone has asked to modify some data? For example, the letter saying "Can you please modify the data in the job description? This is where the 'view' can check whether you have permission to do so, so the job description should be updated to say "Done! That's where the 'view' creates a response and Django seeks to forward it to the person's browser on the spot.

Of course, the description shown has been simplified, but for now it's not necessary to know all the modalities. Simply loading a general idea is more than enough.

That's why we won't go into so much detail, we'll just start with creating something in Django and you'll learn every relevant key along the way.

From Django's website we can see some highlights, in which we can observe some websites such as National Geografic, Disqus, Instagram, Mozilla Foundation and Pinterest, which are websites with a very high traffic and use Django.

In the next article, I will explain how to install Django.

But now let me explain the advantages of using Django.

Why use Django

The main reasons for using Django are:

  1. It's very fast: If you have a startup, are in a hurry to finish your project or simply want to reduce costs, with Django you can build a very good application in a short time.

  2. It comes well loaded: Whatever you need to do, it will already be implemented, you just have to adapt it to your needs. Whether it's because there are community modules, any Python package you find, or the applications Django comes with, they're very useful.

  3. It's pretty safe: We can rest assured that Django implements some security measures by default, the most classic ones, so that there is no SQL Injection, no Cross site request forgery (CSRF) or JavaScript Clickjacking. Django handles all of this in a really simple way.

  4. It's very scalable: we can go from very little to a huge application perfectly, an application that is modular, that works fast and is stable.

  5. It's incredibly flexible: It's true that at first Django started out as a framework for storing news for press sites, blogs and this style of website, but over time it has gained so much popularity that it can be used for any purpose you want.

Other advantages offered by Django

Other benefits of Django that are not highlighted on the website are: 

Its ORM, its interface for accessing the database, since making queries with it is a wonder, is a very good tool.

It comes standard with an administration panel, with which we can leave people without any technical knowledge handling important data in a very comfortable way.

Conclusions

In general, if you have used Symfony in PHP or Ruby on Rails, Django is similar. If you like the ones above, I'm sure this one will, and if you like them, you should give it a try.

Top comments (0)