How to setup a Django Wagtail project?

Hi, I’m trying to deploy my Wagtail application but I have no idea what the best practices are in DigitalOcean. Can someone help?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Site Moderator
Site Moderator badge
August 2, 2023
Accepted Answer

Hey @itsremco,

I’ll be happy to assist.

  1. SSH into the Droplet: Once the Droplet is created, you can SSH into it using the command line. Open your terminal (or use an SSH client like PuTTY on Windows) and connect to the Droplet using its IP address and your ssh key

  2. Update the System: After logging in, update the system packages to ensure you have the latest software:

sudo apt update
sudo apt upgrade
  1. Install Required Dependencies: Install the necessary dependencies for your Django and Wagtail project:
sudo apt install python3-pip python3-venv git
  1. Set Up a Python Virtual Environment: It’s a best practice to work within a Python virtual environment to isolate your project’s dependencies. Create a new virtual environment:
python3 -m venv myprojectenv
source myprojectenv/bin/activate
  1. Clone Your Django Wagtail Project: Use git to clone your Django Wagtail project from a Git repository (if you have your code hosted there):
git clone your_repo_url myproject
  1. Install Project Dependencies: Navigate to your project directory and install the required Python packages using pip:
cd myproject
pip install -r requirements.txt
  1. Configure the Database: Set up your database settings in the Django project’s file. You can use SQLite for development or choose a more robust database like PostgreSQL or MySQL for production. Alternatively, I’ll recommend using DigitalOcean Managed Databases to configure a database. The bonus is that you wouldn’t have to manage it and can focus only on developing your project rather wasting time with configuring and managing the database:

  1. Run Migrations: Apply the database migrations to create the necessary tables:
python migrate
  1. Create a Super user for the django admin interface
python createsuperuser
  1. Collect Static Files: Collect the static files:
python collectstatic
  1. Test the Development Server: Start the Django development server to test if your project is working correctly:
python runserver
  1. Set Up Gunicorn and Nginx (Optional): For production, it’s recommended to use a production-ready web server like Gunicorn and Nginx to serve your Django application. Install Gunicorn and Nginx and configure them to serve your Wagtail project. You can follow this tutorial to configure it:

  1. Configure Domain and SSL (Optional): If you have a domain, configure it to point to your Droplet’s IP address. You can use Let’s Encrypt to obtain SSL certificates and secure your website with HTTPS.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel