Skip to main content

Wagtail-TreeModelAdmin

Build Status Coverage Status

TreeModelAdmin illustration with the books and authors example below

Wagtail-TreeModelAdmin is an extension for Wagtail's wagtail-modeladmin that allows for a page explorer-like navigation of Django model relationships within the Wagtail admin.

Dependencies

  • Python 3.13 – 3.14
  • Django 5.2 (LTS) – 6.0
  • Wagtail 7.0 (LTS) – 7.4 (LTS)
  • wagtail-modeladmin

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

Installation

  1. Install wagtail-treemodeladmin:
pip install wagtail-treemodeladmin
  1. Add treemodeladmin (and wagtail_modeladmin if it's not already) as an installed app in your Django settings.py:
INSTALLED_APPS = (
    ...
    'wagtail_modeladmin',
    'treemodeladmin',
    ...
)

Concepts

Wagtail-TreeModelAdmin allows for a Wagtail page explorer-like navigation of Django one-to-many relationships within the Wagtail admin. In doing this, it conceptualizes the Django ForeignKey relationship as one of parents-to-children. The parent is the destination to of the ForeignKey relationship, the child is the source of the relationship.

Wagtail-TreeModelAdmin is an extension of wagtail-modeladmin. It is intended to be used exactly like ModelAdmin.

Usage

Quickstart

To use Wagtail-TreeModelAdmin you first need to define some models that will be exposed in the Wagtail Admin.

# libraryapp/models.py

from django.db import models


class Author(models.Model):
    name = models.CharField(max_length=255)


class Book(models.Model):
    author = models.ForeignKey(Author, on_delete=models.PROTECT)
    title = models.CharField(max_length=255)

Then create the TreeModelAdmin subclasses and register the root the tree using modeladmin_register:

# libraryapp/wagtail_hooks.py
from wagtail_modeladmin.options import modeladmin_register

from treemodeladmin.options import TreeModelAdmin

from libraryapp.models import Author, Book


class BookModelAdmin(TreeModelAdmin):
    model = Book
    parent_field = "author"


@modeladmin_register
class AuthorModelAdmin(TreeModelAdmin):
    menu_label = "Library"
    menu_icon = "list-ul"
    model = Author
    child_field = "book_set"
    child_model_admin = BookModelAdmin

Then visit the Wagtail admin. Library will be in the menu, and will give you a list of authors, and each author will have a link that will take you to their books.

API

Wagtail-TreeModelAdmin uses three new attributes on ModelAdmin subclasses to express parent/child relationships:

  • parent_field: The name of the Django ForeignKey on a child model.
  • child_field: The related_name on a Django ForeignKey.
  • child_model_admin

Any TreeModelAdmin subclass can specify both parent and child relationships. The root of the tree (either the TreeModelAdmin included in a ModelAdminGroup or the @modeladmin_registered TreeModelAdmin subclass) should only include child_* fields.

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

Credits and references

  1. Forked from cfgov-refresh

Metadata

Release files for wagtail-treemodeladmin 1.12.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-treemodeladmin 1.12.0
File Size Uploaded
wagtail_treemodeladmin-1.12.0.tar.gz 183.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for wagtail-treemodeladmin 1.12.0
File Interpreter ABI Platform
wagtail_treemodeladmin-1.12.0-py3-none-any.whl Python 3 none any Details

Total release size: 203.3 kB

Release files / wagtail_treemodeladmin-1.12.0.tar.gz

Download URL wagtail_treemodeladmin-1.12.0.tar.gz
Size 183.0 kB
Tags Source
SHA-256 checksum
How to use checksums
1a1f0449f46e3bccdd044eb0c42ce8b767113f9d970e85f731697b986d5dd8c7
BLAKE2b-256 checksum
How to use checksums
509a5a90ee742a5304a7688de2b8d93924297f54f018a75fbaa00eb904ed0d8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 29, 2026.

Transparency log

Release files / wagtail_treemodeladmin-1.12.0-py3-none-any.whl

Download URL wagtail_treemodeladmin-1.12.0-py3-none-any.whl
Size 20.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
12452f71062c986af9fbf73e4dfd0e218a5a5cfac26b0120b854dbb9e3b2e450
BLAKE2b-256 checksum
How to use checksums
da40d7a43f5c7c9d38fd8066d2e07b588d58aa3dfee9cf4e9a9971c072171cfe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 29, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.12.0 This release

2 release files

1.11.0

2 release files

1.10.2

2 release files

1.10

2 release files

1.9.2

2 release files

1.9.1

2 release files

1.9.0

2 release files

1.8.0

2 release files

1.7.0

2 release files

1.6.0

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.1

3 release files

1.1.0

1 release file

1.0.5

3 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

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