Installation and Configuration of Wagtail (Django)
Wagtail requires Python 3.8+, Django 4.2+. For production, PostgreSQL, Redis (cache/queue), Gunicorn/uWSGI, Nginx.
Project Creation
pip install wagtail
wagtail start myproject
cd myproject
pip install -r requirements.txt
python manage.py migrate
python manage.py createsuperuser
python manage.py runserver
requirements.txt
# requirements/base.txt
wagtail>=5.2
django>=4.2
psycopg2-binary>=2.9
pillow>=10.0
django-storages[boto3]>=1.14
django-redis>=5.4
gunicorn>=21.0
whitenoise>=6.5
wagtailmetadata>=4.0
wagtail-color-panel>=1.4
# requirements/dev.txt
-r base.txt
django-debug-toolbar>=4.2
django-extensions>=3.2
factory-boy>=3.3
# requirements/production.txt
-r base.txt
sentry-sdk>=1.35
settings/production.py
from .base import *
import os
DEBUG = False
SECRET_KEY = os.environ['SECRET_KEY']
ALLOWED_HOSTS = [os.environ.get('DOMAIN', 'mysite.com')]
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.environ['DB_NAME'],
'USER': os.environ['DB_USER'],
'PASSWORD': os.environ['DB_PASSWORD'],
'HOST': os.environ.get('DB_HOST', 'localhost'),
'PORT': os.environ.get('DB_PORT', '5432'),
'CONN_MAX_AGE': 60,
}
}
CACHES = {
'default': {
'BACKEND': 'django_redis.cache.RedisCache',
'LOCATION': os.environ.get('REDIS_URL', 'redis://localhost:6379/1'),
'OPTIONS': {'CLIENT_CLASS': 'django_redis.client.DefaultClient'},
'TIMEOUT': 3600,
}
}
# Static files via WhiteNoise or S3
STORAGES = {
'default': {
'BACKEND': 'storages.backends.s3boto3.S3Boto3Storage',
},
'staticfiles': {
'BACKEND': 'whitenoise.storage.CompressedManifestStaticFilesStorage',
},
}
AWS_STORAGE_BUCKET_NAME = os.environ['AWS_BUCKET']
AWS_S3_REGION_NAME = os.environ.get('AWS_REGION', 'eu-west-1')
AWS_S3_CUSTOM_DOMAIN = os.environ.get('CDN_DOMAIN')
WAGTAILIMAGES_MAX_IMAGE_PIXELS = 128 * 1024 * 1024 # 128MP
Docker Compose
version: '3.8'
services:
web:
build: .
command: gunicorn myproject.wsgi:application --bind 0.0.0.0:8000 --workers 3
volumes:
- .:/app
env_file: .env
depends_on:
- db
- redis
db:
image: postgres:15
volumes:
- postgres_data:/var/lib/postgresql/data
environment:
POSTGRES_DB: myproject
POSTGRES_USER: myproject
POSTGRES_PASSWORD: secret
redis:
image: redis:7-alpine
volumes:
- redis_data:/data
nginx:
image: nginx:alpine
ports:
- "80:80"
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf
- ./staticfiles:/var/www/static
volumes:
postgres_data:
redis_data:
Dockerfile
FROM python:3.12-slim
ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
WORKDIR /app
RUN apt-get update && apt-get install -y libpq-dev gcc && rm -rf /var/lib/apt/lists/*
COPY requirements/production.txt .
RUN pip install --no-cache-dir -r production.txt
COPY . .
RUN python manage.py collectstatic --noinput
EXPOSE 8000
Management Commands
python manage.py migrate
python manage.py collectstatic
python manage.py rebuild_references_index # relationships index
python manage.py wagtail_update_image_renditions # recreate transformations
python manage.py search_garbage_collect # search cleanup
Wagtail installation with PostgreSQL and S3 for production takes 4–8 hours.







