Django Python Web Framework
June 2, 2026 2 min read

Deploy Django Project on DigitalOcean Droplet

Hs
Hemant singh
Technical Writer & Educator

1. Create a New User

adduser username
usermod -aG sudo username

To delete the user (if needed):

sudo deluser username

Now login with the new user:

ssh username@ipaddress

2. Install Required Packages

sudo apt update && sudo apt upgrade -y
sudo apt install python3-pip python3-dev libmysqlclient-dev build-essential libssl-dev libffi-dev python3-venv git mysql-server nginx pkg-config ufw -y

Make sure MySQL is installed and running properly.

3. Create SSH Keys and Add to GitHub

ssh-keygen -t ed25519 -C "your_email@example.com"
cat ~/.ssh/id_ed25519.pub

Add the public key to your GitHub SSH settings and test it:

ssh -T git@github.com

4. Clone GitHub Repo to /var/www

cd /var/www
sudo mkdir pythonct
sudo chown -R username:www-data /var/www/pythonct
cd pythonct
git clone git@github.com:CAPSCOM-TECHNOLOGY/pythonct.git .

Note: Use dot (.) to clone into the current directory.

5. Set Up Python Virtual Environment

python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt

6. Migrate & Collect Static Files

python manage.py migrate
python manage.py collectstatic

7. Set Up Gunicorn

Test Gunicorn:

gunicorn --bind 0.0.0.0:8000 myproject.wsgi:application

Create Gunicorn service file:

sudo nano /etc/systemd/system/gunicorn.service

8. Configure Nginx

sudo nano /etc/nginx/sites-available/myproject

Make sure to update ALLOWED_HOSTS in settings.py to include your server IP.

Then restart Gunicorn:

sudo systemctl restart gunicorn

That’s it! Your Django app should now be live on your DigitalOcean droplet.