Django is a Python web framework for building web applications that run on a web server. It turns a browser visit into Python code: Django matches a URL to a view, and the view returns a response. This lets people use an application through a browser without installing its Python requirements locally. section 1.0 section 1.1
Figure 1.1 Django handling a page visit
A page visit moves from browser to web server, through WSGI to Django, then from URL mapping to a view and back as a response. section 1.1
Django is a framework rather than a library: it controls the overall execution flow and calls application code at the appropriate point. A site is organized as a Django project, with application code placed in apps. section 2.1 section 2.9
Its core mental model has three connected parts:
- URL routing maps a requested path to a view function or class. section 1.1 section 1.1.1
- Views coordinate a request and produce content for the browser. section 1.1 section 2.9
- The ORM represents database storage through Python objects, while templates compose HTML from reusable pieces. section 1.1 section 1.2
Django is especially suited to dynamic, multipage sites: content changes when a page is visited, often by querying stored objects and rendering a template. Its built-in tools also support authentication, authorization, and database administration for multiuser applications. section 1.1.1 section 1.1.4 section 1.2
Starting a site and its first page
Create a project with django-admin startproject, then create an app with python manage.py startapp and add it to INSTALLED_APPS. Define a view in views.py that accepts a request and returns an HttpResponse, then register it with path() in urls.py. The framework receives the URL and invokes that view. section 2.9
A practical application can grow from public pages into a multiuser service with logins, password management, user input, uploads, database-backed content, and admin pages. Django can also serve as a backend for single-page applications, mobile applications, or machine-to-machine communication; HTMX can add interactive page updates with little extra JavaScript. section 1.2.4 section 1.2.2 section 12.0

