skillfed

wagtail-factories

Factory boy classes for wagtail

wagtail-factories v4.5.0 533.0K downloads/30d#6,143 on PyPI113
Permissive license MIT Active released

What it is and what it does

wagtail-factories is a testing utility that extends factory-boy to generate Wagtail CMS objects—pages, content blocks, and StreamField values—for use in unit and integration tests. It provides pre-built factory classes for common Wagtail types (PageFactory, StructBlockFactory, ListBlockFactory, ImageChooserBlockFactory) and allows you to compose them declaratively to build complex nested content structures on the fly, eliminating the need to manually construct test data in your test suite.

The package is designed for developers writing tests against Wagtail-based applications. Instead of creating pages and blocks by hand in test setup, you define factory subclasses that mirror your model structure, then instantiate them with minimal parameters. It handles the boilerplate of populating required fields, nesting blocks, and managing relationships, making test code more readable and maintainable.

Use it for:

  • Generate realistic Wagtail page hierarchies and StreamField content for testing page rendering and query logic.
  • Create factory classes for custom block types to populate test data with nested structures like carousels or galleries.
  • Build parameterized test fixtures that vary content structure and field values without duplicating setup code.
  • Test Wagtail page chooser blocks and other relational fields by auto-generating linked pages.
  • Simplify integration tests that require a populated Wagtail page tree with specific content blocks.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides factory-boy classes for generating test fixtures and mock data for Wagtail CMS models, pages, and content blocks.

Yes. wagtail-factories is actively maintained, has no known vulnerabilities, low install friction, and a permissive license. It directly solves a common pain point in Wagtail testing by reducing boilerplate. Install it if you write tests for Wagtail applications and want cleaner, more maintainable test fixtures.

Install

wagtail-factories on PyPI

pip

pip install wagtail-factories

uv

uv add wagtail-factories

poetry

poetry add wagtail-factories

Installing wagtail-factories

Before you install

Low friction install with just two runtime dependencies (factory-boy and wagtail). Actively maintained with a recent release and steady commit activity.

License in practice

MIT license permits unrestricted use, modification, and distribution with minimal restrictions—suitable for both open-source and proprietary projects.

Quickstart

pip install wagtail-factories

import wagtail_factories
from factory import SubFactory

class MyPageFactory(wagtail_factories.PageFactory):
    body = wagtail_factories.StreamFieldFactory({
        'text': SubFactory(wagtail_factories.CharBlockFactory),
    })
    class Meta:
        model = MyPage

page = MyPageFactory(title="Test Page")

Requires Python 3.10 or later; wagtail and factory-boy must be installed.

Verify before relying

  • Whether the package supports Wagtail versions beyond 7, given the classifier lists only Wagtail :: 7.
  • Whether nested StreamBlock factories work reliably in all use cases, as the documentation notes this was added in version 3.0.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 2 — factory-boy, wagtail
Maintenance actively maintained — 71 days since the last release
Last repo commit
First released
Downloads 533,011/month — #6,143 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: wagtail_factories-4.5.0-py3-none-any.whl

Development Status :: 5 - Production/StableFramework :: DjangoFramework :: Django :: 4.2Framework :: Django :: 5.2Framework :: Django :: 6.0Framework :: WagtailFramework :: Wagtail :: 7Intended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPy

Tags

wagtail test fixturesfactory boy wagtailwagtail mock data generationwagtail page factorystreamfield test factorywagtail cms testingwagtail block factories
wagtailtestingfixtures

More Testing packages