Last modified: Jun 16, 2025 By Alexander Williams

Install Wagtail CMS with Django in Python

Wagtail is a powerful CMS built on Django. It offers flexibility and ease of use. This guide will help you install Wagtail with Django.

Prerequisites

Before installing Wagtail, ensure you have Python installed. You also need pip, the Python package manager.

Check your Python version with python --version. It should be 3.7 or higher.


python --version

If you need to install Python, download it from the official website.

Create a Virtual Environment

It's good practice to use a virtual environment. This keeps your project dependencies isolated.

Create a virtual environment with venv:


python -m venv wagtail_env

Activate the environment:


# On Windows
wagtail_env\Scripts\activate

# On macOS/Linux
source wagtail_env/bin/activate

Install Django and Wagtail

With the environment activated, install Django and Wagtail:


pip install django wagtail

This will install the latest stable versions of both packages.

Create a New Wagtail Project

Use Wagtail's start command to create a new project:


wagtail start mysite

This creates a new Django project with Wagtail pre-configured.

Set Up the Database

Wagtail uses Django's database system. Run migrations to set up the database:


cd mysite
python manage.py migrate

This creates the necessary database tables.

Create a Superuser

Create an admin account to access the Wagtail admin interface:


python manage.py createsuperuser

Follow the prompts to set up your admin credentials.

Run the Development Server

Start the development server to see your Wagtail site:


python manage.py runserver

Open your browser to http://127.0.0.1:8000 to see the site.

Visit http://127.0.0.1:8000/admin to access the admin panel.

Basic Wagtail Configuration

Wagtail comes with sensible defaults. You can customize settings in mysite/settings/base.py.

For production, you'll want to set ALLOWED_HOSTS and SECRET_KEY properly.

Creating Your First Page

Wagtail uses a tree structure for pages. Let's create a simple home page.

First, create a new app for your pages:


python manage.py startapp home

Add 'home' to INSTALLED_APPS in your settings.

Then create a basic page model in home/models.py:


from wagtail.models import Page
from wagtail.fields import RichTextField

class HomePage(Page):
    body = RichTextField(blank=True)

    content_panels = Page.content_panels + [
        FieldPanel('body'),
    ]

Migrate and Create Home Page

After creating your page model, run migrations:


python manage.py makemigrations
python manage.py migrate

Then create a home page in the Wagtail admin interface.

Extending Wagtail

Wagtail can be extended with various plugins. For example, you might want to install Gradio for machine learning interfaces.

You can also integrate other Python tools like Prefect for workflow orchestration.

Deployment Considerations

For production deployment, you'll need to:

1. Set up a proper database (PostgreSQL recommended)

2. Configure static files properly

3. Set up caching

4. Implement proper security measures

Conclusion

Wagtail is a powerful CMS that builds on Django's strengths. This guide covered the basic installation process.

With Wagtail installed, you can now build sophisticated content-driven websites. For more advanced features, check the official documentation.

If you're working with data, you might also find Great Expectations for data validation useful.