How to Install Django on Mac with Homebrew and Run a Local Development Server

This guide walks through installing Django on macOS step by step, from installing Python via Homebrew through to launching a local development server. Written for beginners.
Test Environment
| Item | Version |
|---|---|
| Machine | MacBook Pro (Apple Silicon) |
| OS | macOS Monterey 12.3.1 |
What Is Django?
Django is an open-source web framework written in Python. It comes with built-in admin interfaces, authentication, and an ORM (database abstraction layer), making it possible to build web applications efficiently without reinventing the wheel. Notable large-scale users include Instagram and Disqus.
The goal of this article is to get Django installed and running locally.
Step 1: Install Homebrew
Django runs on Python, so the first step is getting Python onto the Mac. There are several ways to do this; using Homebrew is the most practical because it also manages updates and other packages.
Paste the following into Terminal and press Enter:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Enter your administrator password when prompted. When you see Installation successful!, Homebrew is ready.
Step 2: Install Python
With Homebrew installed, install Python:
brew install python3
Confirm the installation:
python3 --version
You should see output like Python 3.x.x.
Step 3: Set the PATH for Homebrew Python
Homebrew installs Python under /opt/homebrew/bin/. To make sure this version takes priority over the system Python at /usr/bin/python3, you need to set your PATH.
Check which Python is currently active:
which python3
If the output is /usr/bin/python3, the PATH needs to be configured. Add the Homebrew path to ~/.zprofile (this file is sourced automatically at login on macOS Monterey and later with zsh):
echo 'export PATH=/opt/homebrew/bin/:$PATH' >> ~/.zprofile
Restart Terminal, then verify:
which python3
# Expected: /opt/homebrew/bin/python3
Step 4: Install Django
Create a Working Directory
Create a project folder and move into it:
mkdir myproject && cd myproject
Set Up a Python Virtual Environment
A virtual environment (venv) creates an isolated Python environment per project, allowing different projects to use different package versions without conflicts. This is standard practice for Python development.
Create and activate a virtual environment named django:
python3 -m venv django
source ./django/bin/activate
When the virtual environment is active, (django) appears at the start of your prompt.
Install Django with pip
With the virtual environment active, install Django:
pip3 install django
When you see Successfully installed django-x.x.x, the installation is complete.
Step 5: Create a Project and Start the Server
Create the Django Project
Use django-admin startproject to generate a project scaffold:
django-admin startproject firstproject
cd firstproject
Start the Local Development Server
python3 manage.py runserver
A successful start looks like this:
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
Django version 4.0.4, using settings 'firstproject.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
The
unapplied migration(s)warning means Django’s internal database (used for the admin panel and authentication) has not been initialized yet. You can safely ignore it for a quick test. Runpython3 manage.py migratelater to clear it.
Open http://127.0.0.1:8000/ in a browser. If you see the Django welcome page, everything is working.
Summary
| Step | Command |
|---|---|
| Install Homebrew | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" |
| Install Python | brew install python3 |
| Configure PATH | echo 'export PATH=/opt/homebrew/bin/:$PATH' >> ~/.zprofile |
| Create virtual environment | python3 -m venv django && source ./django/bin/activate |
| Install Django | pip3 install django |
| Create project | django-admin startproject firstproject |
| Start server | python3 manage.py runserver |
From here, the official Django tutorial is the best next step — it covers views, models, and templates in a structured way.