Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Wagtail
  3. Wagtail Factories

Wagtail Factories

MITPythonv4.5.0

Factory Boy classes for generating test data in Wagtail CMS projects.

Visit WebsiteGitHubGitHub
113 stars47 forks0 contributors

What is Wagtail Factories?

Wagtail Factories is a Python library that provides Factory Boy classes for generating test data in Wagtail CMS projects. It allows developers to easily create instances of Wagtail pages, blocks, and other models for testing purposes. The library simplifies the process of setting up complex data structures like StreamFields with nested blocks.

Target Audience

Wagtail developers and Django developers who need to write tests for Wagtail-based applications and want a structured way to generate test fixtures.

Value Proposition

It offers a declarative and reusable approach to creating test data specifically tailored for Wagtail's data models, reducing boilerplate code and improving test reliability. Developers choose it because it integrates seamlessly with factory_boy and provides specialized factories for Wagtail's unique block and page structures.

Overview

Factory boy classes for wagtail

Use Cases

Best For

  • Generating test data for Wagtail Page models
  • Creating complex StreamField fixtures with nested blocks
  • Writing unit tests for Wagtail block components
  • Setting up test databases with realistic Wagtail content
  • Automating test data creation for Wagtail-based applications
  • Testing Wagtail's ListBlock and StructBlock implementations

Not Ideal For

  • Projects not built on Wagtail CMS, as the library is tightly coupled to Wagtail's data models and block system.
  • Teams that prefer static fixture files (e.g., JSON or YAML) for test data, since it relies on programmatic factory generation.
  • Simple Wagtail sites with minimal custom pages or blocks, where the overhead of setting up factories may outweigh the benefits.

Pros & Cons

Pros

StreamField and Block Support

Offers dedicated factories for Wagtail's complex StreamField and block types like StructBlock and ListBlock, enabling easy creation of nested data structures as shown in the README's carousel example.

Factory Boy Integration

Seamlessly builds on factory_boy, allowing developers to use its declarative syntax and deep object declaration for setting nested field values, reducing test boilerplate.

Reduces Test Boilerplate

Eliminates manual setup of Wagtail models in tests, making code cleaner and more maintainable through reusable factory classes, as demonstrated in the provided usage snippets.

Flexible Data Generation

Supports customizable field values via keyword arguments, giving precise control over test data, such as overriding defaults in nested blocks like in the body__0__carousel example.

Cons

Incomplete Documentation

The README explicitly states that documentation is 'still in progress', forcing users to rely on test examples, which can slow onboarding and increase debugging time.

Breaking Syntax Changes

Version 3.0 introduced mandatory updates, such as requiring SubFactory wrappers for block factories in the alternative StreamFieldFactory syntax, potentially breaking existing test code.

Dependency on External Library

Tightly coupled to factory_boy, so teams not already using it must adopt an additional dependency, adding complexity to the toolchain and learning curve.

Frequently Asked Questions

Quick Stats

Stars113
Forks47
Contributors0
Open Issues20
Last commit3 months ago
CreatedSince 2016

Tags

#wagtail#python#testing#cms#django#test-data#test-factories

Built With

P
Python
W
Wagtail

Links & Resources

Website

Included in

Wagtail2.2k
Auto-fetched 10 hours ago

Related Projects

wagtail-linkcheckerwagtail-linkchecker

A tool to assist with finding broken links on your wagtail site.

Stars53
Forks20
Last commit2 years ago
Wagtail AccessibilityWagtail Accessibility

✅ Accessibility content checks for Wagtail websites

Stars36
Forks4
Last commit4 months ago
Wagtail FoliageWagtail Foliage

Utilities for programmatically building page trees in Wagtail.

Stars17
Forks3
Last commit2 years ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub