Before we learn Django, let’s understand:
What is a Web Framework?
A web framework is a code library which helps you to build a flexible, scalable, and maintainable; dynamic website, web app, and web services. Different web frameworks are Zend for PHP, Ruby on Rails for Ruby, etc.
What is Django?
Django is a web development framework for Python which offers a standard method for fast and effective website development. It helps you to assists in building and maintaining quality web applications. It enables you to make the development process smooth and time-saving.
It is a high-level web framework which allows performing rapid development. The primary goal of this web framework is to create complex database-driven websites.
In this tutorial, you will learn
- What is a Web Framework?
- What is Django?
- Why Django? Key Advantages
- History of Django
- Features of Django
- Characteristics of Django
- Django Architecture
- Components of Django
- Famous Companies Using Django
- Disadvantages of using Django
Why Django? Key Advantages
Here, are prime reasons for using Django:
- Django is easy to set up and run. It offers a variety of options to get started
- It provides a ready-to-use user interface for administrative activities
- It enables multilingual websites by using its built-in internationalization system
- Helps you to meet the massive traffic demands quickly
- Django is used to build all types of content management systems, social networks as well as scientific computing platforms.
- Django helps you to provide end-to-end application testing
- Helps you to document your API with an HTML output
- REST Framework has rich support for several authentication protocols
- Permissions and throttling policies
- It is widely used for rate limiting API requests from a single user.
History of Django
- The project was started by Adian Holovaty and Simon Willison as an internal project at Lawrence Journal-World newspaper in 2003
- It was released In July 2005 as “Django,” named after the jazz guitarist Django Reinhard
- In June 2008, it was declared that a Django Software Foundation (DSF) would maintain Django.
- Django 1.1 version was released on July 29, 2009, with features like Aggregates, transaction-based tests.
- Django 1.2 version was released on May 17th, 2010. The update offered features like multiple databases, Implementation of email backend and improvements for sessions and cookie are made in this version.
- On 23 Mar 2011, 1.3 version with features like Class-based views, static files were introduced
- On 23 Mar 2012, 1.4 version launched with new features like timezones and in-browser testing
- On 26 Feb 2013,1.5 version comes with Python 3 Support, configurable user model features.
- On 6 Nov 2013, 1.6 version comes with DB transaction management, connection pooling features.
- On 2 Sep 2014. 1.7 version had new features like application load, migrations, and configuration
- On, 1 Apr 2015 native support provided for multiple template engines.
- On, 1 Dec 2015, in 1.9 version, automatic password validation feature was introduced.
- On, 1 Aug 2016, in 1.10 version full-text search for PostgreSQL launched.
- On, 4 Apr 2017, 1.11 version becomes the last version to support Python 2.7
- On, 2 Dec 2017, version 2.0 becomes first python 3- only release version.
- On, 1 Aug 2018, version 2.1 comes with Model “view” permission support feature.
Features of Django
- Helps you to define patterns for the URLs in your application
- Simple but powerful URL system
- Built-in authentication system
- Object-oriented programming language database which offers best in class data storage and retrieval
- Automatic admin interface feature allows the functionality of adding, editing and deleting items. You can customize the admin panel as per your need.
- Cache framework comes with multiple cache mechanisms.
Characteristics of Django
- Loosely Coupled − Django helps you to make each element of its stack independent of the others.
- Less code - Ensures effective development
- Not repeated- Everything should be developed in precisely one place instead of repeating it again
- Fast development- Django’s offers fast and reliable application development.
- Consistent design - Django maintains a clean design and makes it easy to follow the best web development practices.
Django Architecture: MVC and MVT
MVC Pattern:
When talking about applications which provide UI (web or desktop), we usually talk about MVC architecture. MVC pattern is based on Model, View, and Controller.
The Model defines the data structure and takes to care for querying the database.
The View defines what data should be presented and returns an HTTP response.
The Controller is that part of the application that handles the user interaction.
Django MVC-MVT pattern
The Model-View-Template (MVT) is a different concept compared to MVC. The main difference between these two architectural patterns is that Django itself manages the Controller part (software code that controls the interactions between the Model and View). The template is an HTML file which mixed with the Django Template Language file which also called DTL.
The below-given diagram shows how all the components of the MVT pattern interact with each other to serve specific to a user request.
As seen in above diagram, a user requests for a resource to Django. Django acts as a controller and checks to the available resource in URL.
If URL maps, a view is called which interacts with model and template. Django then responds to the user and sends a template as a response.
Components of Django
Form:
Django has a powerful form library which handles rendering forms as HTML. The library helps in validating submitted data and converting it to Python types.
Authentication:
It handles user accounts, groups, cookie-based user sessions, etc.
Admin:
It reads metadata in your models to provide a robust interface which can be used to manage content on your site.
Internationalization:
Django provides support for translating text into various languages, locale-specific formatting of dates, times, numbers, and timezones.
Security:
Django provides safeguard against the following attacks:
- Cross-Site Request Forgery (CSRF)
- Cross-site scripting
- SQL injection
- Clickjacking
- Remote code execution
Famous Companies Using Django
Here, are companies which are using Django:
- BitBucket
- DISQUS
- NASA
- PBS (Public Broadcasting Service)
- Mozilla
- The Washington Post
- NY Times
- LA Times
- The Guardian National Geographic
- Discovery Channel
Disadvantages of using Django
- A process cannot handle multiple requests simultaneously.
- Django is a very much monolithic tool.
- Components get deployed together which can create confusion.
- Knowledge of full system needed to work on Django
- Makes web application components tightly-coupled
- You need to do lengthy programming for minor tasks.
Summary
- Django is a web development framework for Python which offers a standard method for fast and effective website development.
- Django started was by Adian Holovaty and Simon Willison as an internal project at Lawrence Journal-World newspaper in 2003
- Django helps you to document your API with an HTML output
- Django allows you to customize the admin panel as per your need.
- Django helps you to make each element of its stack independent of the others.
- The main difference between MVC and MVT architectural patterns is that Django itself manages the Controller part.
- Essential components of Django’s architecture are:Form, Authentication, Admin, Internationalization, Security
- Bitbucket, DISQUS, Nasa, Pinterest, Instagram, Mozilla, etc. use Django
- The biggest drawback of Django is that it can’t handle multiple requests simultaneously.