by DigitalOcean

Version 2.2.12

OS Ubuntu 20.04

Create Django Droplet


Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. Built by experienced developers, it takes care of much of the hassle of Web development, so you can focus on writing your app without having to reinvent the wheel. It’s free and open source.

Software Included

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.

API Creation

In addition to creating a Droplet from the Django 1-Click App via 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’ll need to either save your API access token to an environment variable or substitute it into 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-18-04"}' \

Support Details

Supported By:DigitalOceanDigitalOcean
Support URL:

More DigitalOcean Links

DigitalOcean Community

Developers supporting developers

Ask a Question

Ask anything related to system administration, programming, devops, open source, or the DigitalOcean platform.

List your 1-Click App in the DigitalOcean Marketplace

Partner with us to build traction for your open source project or software company