Skip to main content

wagtail-content-audit

Content audit utilities for Wagtail. Still a work in progress.

For Wagtail sites with deeply-nested blocks and a large amount of potentially old content, it can be helpful to inspect block usage and be able to search through the content as it exists in the database. This library is intended to help with these and other challenges of auditing the content in Wagtail.

Dependencies

  • Python 3.12+
  • Django 5.2 (LTS)+
  • Wagtail 6.3 (LTS)+

It should be compatible at all intermediate versions, as well. If you find that it is not, please file an issue.

Installation

  1. Install wagtail-content-audit:
pip install wagtail-content-audit
  1. Add wagtail_content_audit as an installed app in your Django settings.py:
INSTALLED_APPS = (
    ...
    "wagtail_content_audit",
    ...
)

Usage

wagtail-content-audit provides two primary audit tools at present:

  • Block usage auditing
  • Page field searching

For both, it provides a QuerySet-like object using queryish that returns instances of a dataclass with relevant result data.

Block usage

Block usage is intended to audit deeply-nested Wagtail Blocks to discover how much these blocks might be used, and wwithin which other blocks and fields that usage occurs.

Block usage management command

wagtail-content-audit provides a management command to run the block usage audit and output CSV results:

./manage.py block_usage

The resulting CSV can be redirected to a file:

./manage.py block_usage > block_usage_audit.csv

The command takes the following arguments:

--pagetype PAGETYPE_AND_FIELD, -p PAGETYPE_AND_FIELD

Limits the audit to the particular page type(s) and Wagtail StreamField as a dotted path. For example,

./manage.py block_usage --pagetype myapp.PageWithContent.content

Will output the blocks used in all myapp.PageWithContent pages' content field.

Block usage QuerySet

from wagtail_content_audit.query import BlockUsageQuerySet

The underlying queryish QuerySet can be used outside of the management management command as well. This QuerySet behaves like any queryish QuerySet, with a limited set of available options.

It can be filtered for page types:

filtered_queryset = BlockUsageQuerySet().filter(page_model="myapp.PageWithContent")

It can be filtered for Wagtail StreamFields:

filtered_queryset = BlockUsageQuerySet().filter(field="content")

And these can be combined:

filtered_queryset = BlockUsageQuerySet().filter(page_model="myapp.PageWithContent", field="content")

The queryset can also be sliced:

sliced_queryset = BlockUsageQuerySet()[:5]

The resulting objects in the queryset are wagtail_content_audit.query.AuditedBlock objects with the following schema:

@dataclass
class AuditedBlock:
    page_model: type
    field: str
    path: str
    block: type
    pages: list
    total_occurrences: int = 0
    pages_count: int = 0
    pages_live_count: int = 0
    pages_in_default_site_count: int = 0

Page search

Page search is intended to enable searching for specific patterns (using regular expressions) in text content in all Wagtail Page model fields.

For StreamFields specifically, it returns explicit block paths within a StreamField (i.e., 0.list.item.1.richtext for a result found in the second child list item in the first child block in the field) as well as the general block path (i.e., list.item.richtext) so that the blocks can be targetted using Wagtail StreamField migrations.

Page search management command

wagtail-content-audit provides a management command to run the page search audit and output CSV results:

./manage.py page_search -s '[tT]est'

The resulting CSV can be redirected to a file:

./manage.py page_search -s '[tT]est' > page_search_test.csv

The command takes the following arguments:

--pagetype PAGETYPE_AND_FIELD, -p PAGETYPE_AND_FIELD

Limits the search to the particular page type(s) and model field as a dotted path. For example,

./manage.py page_search -s '[tT]est' --pagetype myapp.PageWithContent.content

Will only search within the content field of myapp.PageWithContent pages.

Page search QuerySet

from wagtail_content_audit.query import PageSearchQuerySet

The underlying queryish QuerySet can be used outside of the management management command as well. This QuerySet behaves like any queryish QuerySet, with a limited set of available options.

It can be searched with any regular expression string:

search_queryset = PageSearchQuerySet().filter(search=r"[tT]est")

It can be filtered for page types:

filtered_queryset = PageSearchQuerySet().filter(search=r"[tT]est", page_model="myapp.PageWithContent")

It can be filtered for model fields:

filtered_queryset = PageSearchQuerySet().filter(search=r"[tT]est", field="content")

And these can be combined:

filtered_queryset = PageSearchQuerySet().filter(search=r"[tT]est", page_model="myapp.PageWithContent", field="content")

The queryset can also be sliced:

sliced_queryset = BlockUsageQuerySet()[:5]

The resulting objects in the queryset are wagtail_content_audit.query.pagesearch.PageMatch objects with the following schema:

@dataclass
class PageMatch:
    page_model: type
    page: Page
    field_name: str
    field_type: str
    stream_field_path: list
    block_type: type
    result_path: list
    matches: list

Getting help

Please add issues to the issue tracker.

Getting involved

General instructions on how to contribute can be found in CONTRIBUTING.

Licensing

  1. TERMS
  2. LICENSE
  3. CFPB Source Code Policy

Metadata

Release files for wagtail-content-audit 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wagtail-content-audit 0.3.0
File Size Uploaded Provenance
wagtail_content_audit-0.3.0.tar.gz 27.0 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for wagtail-content-audit 0.3.0
File Interpreter ABI Platform
wagtail_content_audit-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 50.0 kB

Release files / wagtail_content_audit-0.3.0.tar.gz

Download URL wagtail_content_audit-0.3.0.tar.gz
Size 27.0 kB
Tags Source
SHA-256 checksum
How to use checksums
bf3bcd59e14be28b5b5b8e45850b13d712adf34e0a89a15329f2728910d42d77
BLAKE2b-256 checksum
How to use checksums
9fd142dbe48e8c19aa7f127d88209a101f131cd4d8b5ac63e5893a10fe20dd62
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 10, 2026.

Transparency log

Release files / wagtail_content_audit-0.3.0-py3-none-any.whl

Download URL wagtail_content_audit-0.3.0-py3-none-any.whl
Size 23.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
198dbd035b3eb76da1c738b90ac1d56d95800e75d34cb4192926fbac12060870
BLAKE2b-256 checksum
How to use checksums
7ba186211d5f19e94143b3c4519233172b42854993de3e72883a68f8363f7174
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 10, 2026.

Transparency log

Security for wagtail-content-audit 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for wagtail_content_audit-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 10, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page