Wagtail CMS

7.3.1 · active · verified Thu Apr 09

Wagtail is an open-source content management system (CMS) built on the Django framework, known for its intuitive content editing interface and flexible development architecture. It is currently at version 7.3.1 and follows a regular release cadence with major versions typically released annually, accompanied by frequent patch and minor releases addressing bug fixes and security updates.

Warnings

Install

Imports

Quickstart

This code snippet demonstrates a basic Wagtail `Page` model with a `StreamField`. The `StreamField` allows content editors to dynamically add and reorder various content blocks (like headings, paragraphs, images, and embeds) on a page. This model should be placed in `models.py` within a Django app of your Wagtail project, then migrate and set up a superuser to access the Wagtail admin.

from django.db import models
from wagtail.models import Page
from wagtail.fields import StreamField
from wagtail import blocks
from wagtail.admin.panels import FieldPanel

class HomePage(Page):
    """
    A simple example of a Wagtail Page model with a StreamField.
    This defines a flexible content structure editable in the Wagtail admin.
    """
    body = StreamField([
        ('heading', blocks.CharBlock(form_classname="full title")), # Simple text block
        ('paragraph', blocks.RichTextBlock()),                      # Rich text editor
        ('image', blocks.ImageChooserBlock()),                     # Image picker
        ('embed', blocks.RawHTMLBlock(icon='code')),               # Raw HTML embed
    ], use_json_field=True, blank=True, null=True)

    # Define the fields that will appear in the Wagtail admin editor
    content_panels = Page.content_panels + [
        FieldPanel('body'),
    ]

    # You would typically also define a template (e.g., home/home_page.html)
    # and potentially an `abstract` page for common fields across your site.

view raw JSON →