Django Get Started
To build a Django site on your own computer you need Python (Django 5.2 supports Python 3.10 – 3.14), a virtual environment to keep the project's packages separate, and the Django package itself. This lesson walks through the setup once; afterwards, every example in this course runs directly in your browser.
Step 1: Check Python
python3 --versionPython 3.13.1
On Windows, the command is usually py --version. If Python is missing, install it from python.org.
Step 2: Create a virtual environment
A virtual environment is a private folder of packages for one project. Create it inside a new project folder and activate it:
mkdir bookshelf && cd bookshelf
python3 -m venv .venv
source .venv/bin/activate(.venv) $
The (.venv) prefix in your prompt shows the environment is active. On Windows, activate it with .venv\Scripts\activate.
Step 3: Install Django
python -m pip install "Django==5.2.*"
python -m django --versionSuccessfully installed Django-5.2.18 asgiref-3.9.1 sqlparse-0.5.3
5.2.18
Tip: Save your dependencies with
pip freeze > requirements.txtso others (and your server) can install exactly the same versions withpip install -r requirements.txt.
Step 4: Create a project
django-admin startproject generates the skeleton of a project. The trailing dot puts it in the current folder instead of creating another nested one:
django-admin startproject mysite .
lsmanage.py mysite
The generated layout:
bookshelf/
├── manage.py # command-line helper: runserver, migrate, createsuperuser …
└── mysite/ # the project's Python package
├── __init__.py
├── settings.py # all configuration: apps, database, templates …
├── urls.py # the root URLconf (URL → view table)
├── asgi.py # entry point for ASGI servers (async)
└── wsgi.py # entry point for WSGI servers such as gunicorn| File | Purpose |
|---|---|
manage.py |
Runs Django commands for this project (python manage.py <command>) |
settings.py |
INSTALLED_APPS, DATABASES, TEMPLATES, DEBUG, SECRET_KEY … |
urls.py |
The list urlpatterns that routes URLs to views |
wsgi.py / asgi.py |
How production servers load your project |
Step 5: Run the development server
python manage.py migrate
python manage.py runserverOperations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
...
Applying sessions.0001_initial... OK
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
October 16, 2026 - 09:30:00
Django version 5.2.18, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
migrate creates the database tables Django's built-in apps need (in a file called db.sqlite3). runserver starts a lightweight web server that reloads automatically when you save a file. Open http://127.0.0.1:8000/ and you'll see Django's rocket "The install worked successfully!" page.
Note:
runserveris for development only. In production you use a real server such as gunicorn or uvicorn — see Settings & Deployment.
Useful manage.py commands
| Command | What it does |
|---|---|
runserver [port] |
Start the development server |
startapp <name> |
Create a new app folder |
makemigrations |
Turn model changes into migration files |
migrate |
Apply migrations to the database |
createsuperuser |
Create an admin user |
shell |
Python shell with your project loaded |
test |
Run the test suite |
check |
Look for configuration problems |
Checking your installation from Python
Everything Django can tell you about itself is also available from Python. This snippet runs in the browser playground with real Django:
import django
from django.conf import settings
settings.configure()
django.setup()
print("Django", django.get_version())
print("VERSION tuple:", django.VERSION)
print("Default DEBUG:", settings.DEBUG)
print("Default time zone:", settings.TIME_ZONE)Django 5.2.18
VERSION tuple: (5, 2, 18, 'final', 0)
Default DEBUG: False
Default time zone: America/Chicago
settings.configure() without arguments uses Django's global defaults. A project generated by startproject overrides many of them — for example it sets TIME_ZONE = "UTC" and DEBUG = True.
Test yourself
Which command creates a new Django project skeleton?
- python manage.py startapp mysite
- django-admin startproject mysite
- pip install mysite
- python -m venv mysite
Which file holds the list of installed apps and the database configuration?
- urls.py
- manage.py
- settings.py
- wsgi.py
Why use a virtual environment for a Django project?
- It makes Django run faster
- It keeps the project's packages isolated from other projects
- It is required by runserver
- It creates the database