Introduction to Django
Django is a high-level Python web framework for building database-driven websites quickly, giving you routing, a database layer, templating, an admin, and security tools out of the box so you can focus on your application's features instead of reinventing the basics.
Learn Introduction to Django in our free Django course — a beginner-friendly interactive lesson with worked examples, a practice exercise and a quick reference.
Part of the free Django course at LearnCodingFast — hands-on lessons with examples you run in your browser, plus practice exercises and a quick quiz.
In this first lesson you'll learn what Django is, why developers reach for it, and how to install it and spin up your very first project.
Django is a free, open-source web framework written in Python. A web framework is a toolkit that provides the common machinery every website needs — receiving HTTP requests, talking to a database, generating HTML, and sending responses back to the browser.
Django follows the MTV pattern — Model, Template, View — which is its take on the classic MVC architecture:
Because Django is "batteries included," it ships with an ORM, an automatic admin site, form handling, authentication, and protection against common web attacks. You write Python; Django handles the plumbing.
Django is installed with pip , Python's package manager. It is best practice to install it inside a virtual environment so each project keeps its own isolated dependencies.
The django-admin startproject command generates the scaffolding for a new project. Then manage.py runserver starts a local development server.
Fill in the blank so the function builds the correct startproject command for a project called blog .
Django isn't installed or your virtual environment isn't active.
✅ Fix: activate the venv and run pip install django again.
✅ Fix: run on a different port: python manage.py runserver 8080
❌ ModuleNotFoundError: No module named 'django'
You're using a Python interpreter where Django isn't installed.
✅ Fix: make sure your virtual environment is activated before running commands.
Write a helper that prints the full sequence of commands needed to start a brand-new Django project from scratch.
Lesson 1 complete — Django is installed and running!
You now know what Django is, why it's "batteries included," how the MTV pattern is organised, and how to install Django, create a project, and run the development server.
🚀 Up next: Projects vs Apps — learn how a Django project is split into reusable apps.
Practice quiz
What kind of framework is Django?
- A JavaScript front-end framework
- A high-level Python web framework
- A CSS styling library
- A database engine
Answer: A high-level Python web framework. Django is a high-level web framework written in Python.
What does 'batteries included' mean for Django?
- It ships with an ORM, admin, templating, auth, and more out of the box
- It requires no Python knowledge
- It includes a physical battery
- It only runs on mobile devices
Answer: It ships with an ORM, admin, templating, auth, and more out of the box. Django bundles most of what a web app needs so you can build immediately.
Which architectural pattern does Django follow?
- MVVM
- MVP
- MTV (Model-Template-View)
- Pub/Sub
Answer: MTV (Model-Template-View). Django uses MTV, its take on the classic MVC architecture.
In Django's MTV pattern, what does the Model represent?
- HTML files with placeholders
- Python classes that describe data and map to tables
- The URL routing table
- CSS stylesheets
Answer: Python classes that describe data and map to tables. Models are Python classes describing data that map to database tables.
Which command creates a new Django project's scaffolding?
- python manage.py runserver
- pip install django
- django-admin startproject mysite
- python -m django --version
Answer: django-admin startproject mysite. django-admin startproject generates the project scaffolding.
Which command starts Django's local development server?
- python manage.py runserver
- django-admin startapp
- pip install django
- python manage.py migrate
Answer: python manage.py runserver. manage.py runserver starts the development server.
How is Django typically installed?
- By downloading a .exe
- It comes preinstalled with Python
- With npm install django
- With pip install django
Answer: With pip install django. Django is installed via pip, Python's package manager.
Why install Django in a virtual environment?
- It makes Django run faster
- It keeps each project's dependencies isolated
- It is required to use pip
- It enables the admin site
Answer: It keeps each project's dependencies isolated. A virtual environment isolates each project's packages from others.
What is a Django view in MTV?
- An HTML template
- A database column
- A function or class that takes a request and returns a response
- A CSS file
Answer: A function or class that takes a request and returns a response. Views take an HTTP request and return a response.
Which file is the command-line utility for a Django project?
- manage.py
- settings.py
- urls.py
- wsgi.py
Answer: manage.py. manage.py is the command-line utility for project tasks.