Skip to content

Introduction

Django is a free and open-source, Python-based web framework. It is maintained by the Django Software Foundation (DSF), an independent non-profit organization established in the US.

Unlike many other Python-based web frameworks, Django follows a "batteries-included" approach, meaning it ships with a rich set of features for web development right out of the box. It provides built-in tools for authentication, an admin interface, an ORM (Object–Relational Mapper), form handling, templating, security, and much more.

Django emphasizes reusability of components, rapid development, and the principle of don't repeat yourself (DRY). It follows the MVT (Model–View–Template) architecture.

MVT Architecture

Django's MVT architecture pattern is very similar to that of MVC (Model–View–Controller) architectural pattern.

The Model

The Model is an abstraction layer for structuring and manipulating the data of your web application. Django comes with an Object–Relational Mapper (ORM), which allows you to interact with the database using Python code instead of writing raw SQL. You define your data models as Python classes, and Django automatically takes care of generating the corresponding database tables, relationships and constraints behind the scenes.

This is similar to the model in MVC architecture.

The View

The View layer handles the logic that processes a user’s request and returns the appropriate response. It retrieves data from the model and passes it to the template for rendering. In Django, views can be written as either Python functions or classes.

Django's View layer is equivalent to the Controller (not View) in MVC architecture.

The Template

The Template layer is the presentation layer responsible for displaying information to the user. It uses the Django Template Language (DTL), a designer-friendly syntax, to render dynamic HTML pages.

Django's Template layer is equivalent to the View in MVC architecture.

Why Django?

Django stands out as a mature, stable, and battle-tested framework. It has been powering high-traffic websites for more than a decade and continues to evolve with modern web needs. Compared to other Web Frameworks, Django has following advantages:

  • Python ecosystem: Django inherits the simplicity, readability, and vast library support of Python, making it easier to learn and extend.
  • Batteries-included: Unlike many frameworks that require numerous plugins, Django comes with ORM, authentication, admin, security features, and more built in.
  • Security focus: Django provides protection against common vulnerabilities like SQL injection, cross-site scripting, cross-site request forgery, and clickjacking by default.
  • Scalability & reliability: Proven in production for companies like Instagram, Mozilla etc., showing it can handle very large applications.
  • Community & longevity: A large, active community ensures ongoing support, rich documentation, and a huge pool of reusable apps and plugins.

Even within Python-based web frameworks, Django remains the preferred choice because it offers a complete, opinionated solution out of the box. While frameworks like Flask or FastAPI are excellent for lightweight apps or APIs, Django’s batteries-included design, strong conventions, and proven scalability make it the go-to option for building robust, full-stack web applications.

Extending Django with DRF

This book also includes a dedicated chapter on Django REST Framework (DRF), as a natural extension to Django. In many modern projects, Django is used purely as a backend service, with frontend built in frameworks like React, Vue, or Angular. In such cases, Django’s role is to provide a robust and secure API that powers the frontend application.

DRF extends Django with powerful tools for building RESTful APIs. Learning it alongside Django gives you the flexibility to build either full-stack applications with Django or API-driven backends with Django + DRF.