Skip to content
Kuza Ndoto Academy

Django Introduction

IntermediateChapter 1 · Page 1 of 234 min readUpdated 15 Nov 2026

Django is a free, open-source web framework written in Python. It gives you ready-made tools for the jobs almost every website needs, such as talking to a database, handling user accounts and building forms, so you can spend your time on the parts that make your site unique.

What is Django?

A web framework is a collection of code, conventions and tools that handles the repetitive work of building websites. Without one, you would have to write your own code to read web requests, connect to a database, protect login pages and generate HTML. Django does all of this for you.

Django started inside a newsroom at the Lawrence Journal-World newspaper in the United States, where developers needed to build news sites quickly and to tight deadlines. It was released as open source in 2005 and is named after the jazz guitarist Django Reinhardt. Today it is maintained by the non-profit Django Software Foundation and used by organisations such as Instagram and Mozilla.

Django's motto is "the web framework for perfectionists with deadlines". In practice this means two things: it helps you build fast, and it pushes you towards clean, secure code.

Why developers choose Django

  • Batteries included: an admin dashboard, a database layer (the ORM), user authentication, forms, sessions and email come built in. You rarely need to hunt for extra packages to get started.
  • Secure by default: Django protects you against common attacks such as SQL injection, cross-site scripting (XSS), cross-site request forgery (CSRF) and clickjacking without extra work.
  • Scales well: the same patterns work for a class project and for a site with millions of users.
  • Excellent documentation: the official docs are some of the best in open source, and the community is large and friendly.
  • It's Python: if you already know Python, you can read Django code from day one.

How a Django website works

Every time you open a page, your browser sends an HTTP request to a server. Django receives that request and works out what to send back. Here is the journey for a page such as /events/:

  1. The browser requests http://example.com/events/.
  2. Django's URL dispatcher looks up which Python function should handle events/.
  3. That function, called a view, asks a model for data, e.g. "give me all upcoming events".
  4. The model fetches the rows from the database.
  5. The view passes the data to a template, an HTML file with placeholders, which produces the finished page.
  6. Django sends the HTML back to the browser as an HTTP response.
Browser HTTP request HTTP response Django urls.py View Model Template find the view, fetch data, build the HTML page
Figure 1. Every page view is one request in and one response out; inside, Django hands the work to URLs, views, models and templates.

This split into models, views and templates is called the MVT pattern, and you will meet it on almost every page of this series.

A first glimpse of Django code

You don't need to understand every line yet. Notice how little code it takes to describe some data and show it on a page.

events/models.py

from django.db import models


class Event(models.Model):
    title = models.CharField(max_length=200)
    venue = models.CharField(max_length=100)
    starts_at = models.DateTimeField()

events/views.py

from django.shortcuts import render

from .models import Event


def event_list(request):
    events = Event.objects.all()
    return render(request, "events/event_list.html", {"events": events})

The model becomes a database table, and the view fetches every event and hands it to a template. No SQL, no manual HTML building.

Django compared with other Python frameworks

FrameworkStyleBest for
DjangoFull-featured, "batteries included"Complete websites with databases, logins and an admin area
FlaskMinimal, you choose the extrasSmall apps and learning how the web works at a lower level
FastAPIModern, focused on APIsJSON APIs for mobile apps and front-end frameworks

None of these is "the best"; they solve different problems. Django shines when you want to build a whole product, such as a SACCO members' portal, a school results system or a campus events site, quickly and safely.

What you will build in this series

Most pages in this series add to one running example: Campus Events, a site where students can browse upcoming events at their university, see the details, sign up to attend and, if they are organisers, create and edit events. The final page brings everything together in a separate blog project.

Note

This series uses Django 5.2, a long-term support (LTS) release, with Python 3.12 or newer. You should be comfortable with Python functions, dictionaries, classes and virtual environments before you start.

Common mistake

Jumping into Django before you know basic Python. Django code is full of classes, imports and keyword arguments. If those feel unfamiliar, spend a week on the Python series first. You'll learn Django much faster afterwards.

Key points

  • Django is a free, open-source Python framework for building database-backed websites.
  • It includes an ORM, admin site, authentication, forms and strong security protections.
  • A request flows from URL to view to model to template, and back to the browser as a response.
  • This series builds a Campus Events site step by step using Django 5.2.
Up next · Getting StartedInstalling DjangoSet up a virtual environment and install Django.
→

Tip: use the ← and → keys to move between pages.