Django
Generated on 24 Jun 2026 from the Django catalog page
Django 1-Click
Deploy Django on Ubuntu 24.04 with PostgreSQL, Gunicorn, and Nginx. By default, PostgreSQL runs locally. You can optionally attach a DigitalOcean Managed PostgreSQL database during deployment.
Getting Started
- Select the Django 1-Click from the DigitalOcean Marketplace
- Choose a Droplet size and region
- Optionally select Add a Database to provision a Managed PostgreSQL database (see below)
- Create the Droplet and SSH in as
root
On first boot, a sample Django project is created and started automatically.
Django admin:
- URL:
http://your-droplet-ip/admin - Username:
django(see/root/.digitalocean_passwords) - Password: stored in
/root/.digitalocean_passwords
Using a DigitalOcean Managed Database (Optional)
When creating your Django Droplet, you can select Add a Database to provision a DigitalOcean Managed PostgreSQL database at the same time. A managed database replaces the local PostgreSQL instance to better secure your data and gives you easy backups, connection pools, and metrics. No manual DBaaS setup is required.
What happens when you add a database
When you choose this option during Droplet creation, DigitalOcean:
- Provisions a Managed PostgreSQL cluster in the same region as your Droplet
- Passes connection credentials to your Droplet at first boot in
/root/.digitalocean_dbaas_credentials
During first-boot setup, the Droplet automatically:
- Waits for the PostgreSQL cluster to become available (this may take a few minutes)
- Creates a dedicated
djangodatabase user anddjangodatabase on the managed cluster - Updates
/home/django/django_project/django_project/settings.pywith the managed host and port - Runs Django migrations against the managed database
- Stops and disables the local PostgreSQL instance
Database credentials for the Django application are stored in /root/.digitalocean_passwords (DJANGO_POSTGRESS_PASS).
Security: Trusted Sources
Your Droplet is not automatically added to the Managed Database’s trusted sources. For better security, add your Droplet’s public IP address to the database cluster’s Trusted Sources in the DigitalOcean control panel:
- Open your database cluster in the control panel
- Go to Settings → Trusted Sources
- Add your Droplet’s public IP address
Modifying database settings later
- Django settings: Update database configuration in
/home/django/django_project/django_project/settings.py - Application password:
/root/.digitalocean_passwords(DJANGO_POSTGRESS_PASS) - Password rotation: If you change the database password in the control panel, update
settings.pyand/root/.digitalocean_passwordsto match
File Locations
- Django project:
/home/django/django_project - Passwords and keys:
/root/.digitalocean_passwords - Setup log:
/var/log/one_click_setup.log
Get your code on here
Clone your Django code onto the droplet, anywhere you like. Note: If you’re not using a source control, you can directly upload the files to your droplet using SFTP.
You can try to reuse this project, located in /home/django/django_project, or start fresh in a new location and edit Gunicorn’s configuration to point to it at /etc/systemd/system/gunicorn.service. You can also change how nginx is routing traffic by editing /etc/nginx/sites-enabled/default
Cd into the directory where your Django code lives, and install any dependencies. (For example, if you have a requirements.txt file, run pip install -r requirements.txt.)
That’s it! Whenever you make code changes, reload Gunicorn like so:
PID=$(systemctl show --value -p MainPID gunicorn.service) && kill -HUP $PID
Play in the admin area
The standard Django admin area is accessible at /admin. The login and password are stored in the DJANGO_USER* values you see when you call cat /root/.digitalocean_passwords while logged in over SSH.
Get production-ready
There’s a lot you’ll want to do to make sure you’re production-ready. Here are the popular things that people will do.
Firewall: Review your firewall settings by calling sudo ufw status, and make any changes you need. By default, only SSH/SFTP (port 22), HTTP (port 80), and HTTPS (port 443) are open. You can also disable this firewall by calling sudo ufw disable and use a DigitalOcean cloud firewall instead, if you like (they’re free).
Domain: Register a custom domain
Storage: You can mount a volume (up to 16TB) to this server to expand the filesystem, provision a database cluster (that runs MySQL, Redis, or PostgreSQL), or use a Space, which is an S3-compatible bucket for storing objects.
Software Included
| Package | Version | License |
|---|---|---|
| Django | 6.0 | Custom |
| Nginx | 1.24.0 | Custom |
| Certbot | 2.9.0 | Apache 2 |
| Gunicorn | 20.1.0 | MIT |
| Postgres | 16.14 | Postgres SQL |
| Postfix | 3.8.6 | IBM Public |
Creating an App using the Control Panel
Click the Deploy to DigitalOcean button to create a Droplet based on this 1-Click App. If you aren’t logged in, this link will prompt you to log in with your DigitalOcean account.
Creating an App using the API
In addition to creating a Droplet from the Django 1-Click App using the control panel, you can also use the DigitalOcean API. As an example, to create a 4GB Django Droplet in the SFO2 region, you can use the following curl command. You need to either save your API access token to an environment variable or substitute it in the command below.
curl -X POST -H 'Content-Type: application/json' \
-H 'Authorization: Bearer '$TOKEN'' -d \
'{"name":"choose_a_name","region":"sfo2","size":"s-2vcpu-4gb","image":"django-20-04"}' \
"https://api.digitalocean.com/v2/droplets"Getting Started After Deploying Django
After you created a Droplet, you can navigate to its public IPv4 address to see the sample application live.
To learn how to make modifications or get your code onto your Droplet, here are the steps. You can also follow the sample application for the instructions.
Step 1: Access to your Droplet
Open a terminal on your computer to access your Droplet as the root user using the following command:
ssh root@your_droplet_public_ipv4
You will then be prompted to enter a password. If you created your Droplet with a root user password, enter this in the terminal. If you created your Droplet with an ssh key, enter the passphrase associated with your key.
Step 2: Get your code on here
Note the login message, it has important details for connecting to your Postgres database, among other things!
Clone your Django code onto the droplet, anywhere you like. Note: If you’re not using a source control, you can directly upload the files to your droplet using SFTP.
You can try to reuse this project, located in /home/django/django_project, or start fresh in a new location and edit Gunicorn’s configuration to point to it at /etc/systemd/system/gunicorn.service. You can also change how nginx is routing traffic by editing /etc/nginx/sites-enabled/default
Cd into the directory where your Django code lives, and install any dependencies. (For example, if you have a requirements.txt file, run pip install -r requirements.txt.)
That’s it! Whenever you make code changes, reload Gunicorn like so:
PID=$(systemctl show --value -p MainPID gunicorn.service) && kill -HUP $PID
Step 3: Play in the admin area
The standard Django admin area is accessible at /admin. The login and password are stored in the DJANGO_USER* values you see when you call cat /root/.digitalocean_passwords while logged in over SSH.
Step 4: Get production-ready
There’s a lot you’ll want to do to make sure you’re production-ready. Here are the popular things that people will do.
Firewall: Review your firewall settings by calling sudo ufw status, and make any changes you need. By default, only SSH/SFTP (port 22), HTTP (port 80), and HTTPS (port 443) are open. You can also disable this firewall by calling sudo ufw disable and use a DigitalOcean cloud firewall instead, if you like (they’re free).
Domain: Register a custom domain
Storage: You can mount a volume (up to 16TB) to this server to expand the filesystem, provision a database cluster (that runs MySQL, Redis, or PostgreSQL), or use a Space, which is an S3-compatible bucket for storing objects.
Managed storage: You can use a managed database instead of a local one to secure your data and enable easy backups, connection pools, and metrics.