So what is Django?
When a lot of people hear “Django” they think about the Tarantino film where a German dentist and bounty hunter, Doctor King Schultz, manages to free Django the slave (played by Jamie Foxx), and he uses him to find the most wanted criminals in the south, making him too into a bounty hunter.
But Django existed before this film. Django is a high-level open source web development framework which adapts largely to the common MVC (Model View Controller) design pattern.
The aim of Django is to enable complex websites to be created, which is also an advantage. For example, it makes starting a project with just 5 files possible.
Another of its biggest advantages is that it is written in Python, an interpreted language whose ethos is placed on syntaxis which is in favour of legible code, allowing for the quick creation of safe and easy-to-maintain websites.
The origin of Django
It was initially developed between 2003 and 2005 by a team that was working on creating and maintaining newspaper websites. After creating several sites, the team started to see and reuse a lot of common design patterns and code. This common code became a general web open-source framework, known as the Django project in July 2005.
These are the features that make Django a good option for web creation.
• It is comprehensive, as it follows the “batteries included” ethos and provides the developer with almost all they need as soon as the project is started. It also has an administration panel as standard, amongst other things, which we can use to manage important data in an easy and simple way.
• It is versatile and virtually any type of website can be built, from management systems and social networks to news websites and APIs… It can also work with any framework on the client’s side, and it can return content in almost any format such as RSS, JSON, XML, HTML…
• It is safe because it is designed to always comply with an accurate design to automatically protect the website. For example, it provides a safe way for managing user accounts and passwords, avoiding any errors. It also offers protection against vulnerabilities on the data base such as SQL injection, scripts between sites, clickjacking…
• It is scaleable: it uses a component based on the “shared-nothing” architecture (each part of the architecture is independent from the others).
• It is maintainable: the Django code is written using design principles and patterns to promote maintainable and reusable code creation.
• It is portable because due to it being written in Python, it can be used on many platforms such as Linux, Windows and Mac OS
• It has a prosperous, active community, is highly documented with lots of free support and payment options. Django also has the support of many web hosting providers.
• The ORM tool helps you to do SQL, without the need to use SQL language, which is known as an interface for access to the database.
Below is an example of what it would be like on a normal SQL or with the Django ORM:
|Query without ORM||Query with ORM|
|SELECT * FROM “authors_author” INNER JOIN “author_book” ON (“authors_author.”id” = “authors_book”.”author_id”)
INNER JOIN “authors_book_bookshop” ON (“authors_book”.”id” = “authors_book_bookshop”.”book_id”)
INNER JOIN “authors_bookshop” ON (“authors_book_bookshop”.”bookshop_id” = “authors_bookshop”.”id”) WHERE “authors_bookshop”.”name” = “La Cultura”
|Author.objects.filter(books_bookshop_name = “La Cultura”)|
Which websites use Django?
I imagine the following examples will be familiar to you…
Shall we start with Django?
If after reading this article you need to build a website, Django could be the solution. If you don’t know how to start, at Sothis we can help you!