Skip to main content

wagtail-mptt-comments

Threaded comments and moderation for Wagtail CMS. The package stores comments as a nested MPTT tree, includes guest anti-spam controls, provides a Wagtail admin moderation interface, and exposes template tags for the comment form/tree and recent-comment widgets.

Use this package for article/page comments. It is not a forum engine and does not provide topics, sections, or private messages.

English · Русский · Deutsch · Español · Français · Italiano · Português (Brasil) · Nederlands · Polski · Türkçe · 简体中文 · 日本語 · 한국어

Comment tree

Features

  • Nested replies powered by django-mptt, with configurable depth.
  • Guest anti-spam checks: honeypot, a signed page-bound form token, a signed math challenge, and per-session replay detection. These are layered friction/rate-limit controls, not a replacement for a WAF or abuse monitoring.
  • Optional moderation for new comments and email notifications to administrators.
  • User, guest, moderator, and administrator badges; optional notification to a comment author when someone replies.
  • Wagtail admin list and tree views, bulk approve/delete actions, and administrator responses.
  • Template tags for rendering a page's comments and a latest-comments sidebar.
  • Multi-site filtering so page comments and recent-comment widgets are restricted to the current Wagtail Site.
  • CSS variables for front-end theming, and a Prose-based editor for comment/admin-response content.

Compatibility

The package metadata declares a minimum of wagtail>=6.0; that is the supported floor, not the full test matrix. The two tested configurations differ in kind: Wagtail 8.0.1 is covered by integration tests of the originating project with editable installs of this package, while Wagtail 8.1 was tested against the target production stack with clean wheel and sdist installs — both with Django 6.0.9 on Python 3.14. Other combinations may work but are not covered by the test suite.

Requirements and installation

Package metadata declares wagtail>=6.0, django-mptt>=0.16.0, django-prose-editor>=0.26, and nh3>=0.2.14.

pip install wagtail-mptt-comments==0.2.8
python -m pip install .

Add the app after its dependencies:

INSTALLED_APPS = [
    # ... Django and Wagtail apps ...
    "mptt",
    "django_prose_editor",
    "wagtail_mptt_comments",
]

Include the URL namespace:

from django.urls import include, path

urlpatterns = [
    # ...
    path("comments/", include("wagtail_mptt_comments.urls")),
]

Apply the package migrations:

python manage.py migrate wagtail_mptt_comments

The package does not require a custom Wagtail Page model. Your commentable page is passed to the template tag.

Render comments in a page template

{% load mptt_comment_tags %}

<h1>{{ page.title }}</h1>
{% render_comments page %}

render_comments supplies the approved comment tree and form. Avoid preparing the same tree/count/form in Page.get_context() as well; duplicate preparation causes repeated database work and can diverge from plugin behavior.

Recent-comments widget

{% load mptt_comment_tags wagtailcore_tags %}

{% get_latest_comments 5 as latest_comments %}
<ul>
  {% for comment in latest_comments %}
    <li>
      <a href="{% pageurl comment.page %}#comment-{{ comment.id }}">
        <strong>{{ comment.display_author_name }}</strong>:
        {{ comment.content|striptags|truncatewords:10 }}
      </a>
    </li>
  {% endfor %}
</ul>

The template tag is intended for the current Wagtail Site. Keep it in a request context where the current request and Site are available. If your project has custom domain routing or serves content outside a configured Wagtail Site, verify that the widget returns no cross-site comments rather than broadening to all sites.

Settings

All settings are optional. Current defaults in the package source are:

Setting Default Meaning
COMMENTS_MODERATION True Guest comments require moderation by default.
COMMENTS_NOTIFY_ADMINS False Email administrators about new comments.
COMMENTS_MODERATOR_GROUPS None Django group names whose members receive the moderator badge/role.
COMMENTS_MAX_LENGTH 20000 Maximum comment text length.
COMMENTS_CAPTCHA_MAX_AGE 7200 seconds Maximum age of the signed math-captcha token.
COMMENTS_FORM_TOKEN_MAX_AGE 7200 seconds Maximum age of the signed page-bound form token.
COMMENTS_TRUST_PROXY_HEADERS False Allow reading a forwarded client-IP chain, but only when REMOTE_ADDR matches a trusted proxy network.
COMMENTS_TRUSTED_PROXY_IPS () Comma-separated IP addresses/CIDRs of trusted reverse proxies. Never use 0.0.0.0/0 or ::/0.
SITE_NAME project-dependent Site name used in messages where needed.
DEFAULT_FROM_EMAIL Django default Sender address for notifications.

Example:

COMMENTS_MODERATION = True
COMMENTS_NOTIFY_ADMINS = True
COMMENTS_MODERATOR_GROUPS = ["Moderators"]
COMMENTS_MAX_LENGTH = 20_000
COMMENTS_TRUST_PROXY_HEADERS = False  # keep false until proxy behavior is verified
COMMENTS_TRUSTED_PROXY_IPS = ()  # e.g. ("10.0.0.10/32",) after confirmation
DEFAULT_FROM_EMAIL = "noreply@example.com"

Set up Django email delivery if notifications are enabled. Review the content and privacy requirements for storing commenter names, email addresses, IP-derived rate-limit data, and notification preferences.

Reverse proxy / rate limiting: keep COMMENTS_TRUST_PROXY_HEADERS=False unless the hosting provider confirms the proxy address range and confirms that X-Forwarded-For is overwritten or appended safely. Then set COMMENTS_TRUST_PROXY_HEADERS=True and list only the provider proxy IPs/CIDRs in COMMENTS_TRUSTED_PROXY_IPS. The package ignores forwarded headers from untrusted peers and walks the chain from right to left. Do not trust arbitrary client-supplied XFF headers.

Styling

Load the package's comments.css and override CSS custom properties in your theme stylesheet. For example:

.article-comments {
  --mptt-bg: #1c2226;
  --mptt-card-bg: #1c2226;
  --mptt-accent: #0e8a86;
  --mptt-accent-hover: #26b5a9;
  --mptt-text: #eaeef0;
  --mptt-border: #2c3437;
}

Use your actual wrapper selector, and load the override after the plugin stylesheet.

Security and operations

  • Keep nh3 and the package dependencies updated. Do not render user-authored HTML with |safe in custom templates.
  • Test guest posting, CSRF, replay attempts in one session, moderation, reply links, email, and collection/site separation with normal users, moderators, and administrators. Cached HTML may be reused across visitors; replay tracking is per session so one visitor does not invalidate another visitor's copy of a cached challenge.
  • When using multiple Wagtail Sites, test the latest-comments widget on every domain, including an unknown/unconfigured host.
  • The source bundle does not include an automated test suite or a complete runtime compatibility matrix. Run migrations and smoke tests against your exact production dependencies before upgrading.
  • wagtail-prose-editor-images is useful if administrator responses or related Prose fields need the Wagtail Image Chooser. The packages are separately installable; test the exact field configuration.
  • wagtail-image-directories complements this package only when the site also needs structured image storage; comments themselves do not require it.
  • Use wagtail-simple-forum for discussion boards and private messages, not as a replacement for article comments.

License and support

MIT. Source and issue tracker: GitHub. Do not include commenter personal data, production tokens, or private URLs in bug reports.

Metadata

Release files for wagtail-mptt-comments 0.2.8

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-mptt-comments 0.2.8
File Size Uploaded Provenance Actions
wagtail_mptt_comments-0.2.8.tar.gz 56.8 kB Without provenance Details for wagtail_mptt_comments-0.2.8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for wagtail-mptt-comments 0.2.8
File Interpreter ABI Platform Actions
wagtail_mptt_comments-0.2.8-py2.py3-none-any.whl Python 3, Python 2 none any Details for wagtail_mptt_comments-0.2.8-py2.py3-none-any.whl

Total release size: 122.9 kB

Release files / wagtail_mptt_comments-0.2.8.tar.gz

Download URL wagtail_mptt_comments-0.2.8.tar.gz
Size 56.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e1d3b7b41a6b36278d3670f27b667d092972d2fcda2fb1e25c1495e51b484280
BLAKE2b-256 checksum
How to use checksums
0d85e080194c87d95ce8ad3239639e196b7ee0aa190f1b6a43b468f7c44a5da3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / wagtail_mptt_comments-0.2.8-py2.py3-none-any.whl

Download URL wagtail_mptt_comments-0.2.8-py2.py3-none-any.whl
Size 66.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
112db53b5743bfd48a10386d667dc383ea3b9d1f8c30bc6665695ce4bfec5ab5
BLAKE2b-256 checksum
How to use checksums
79ca4df8b91e81ec24b5209f74e60e7b0283c05b5835ba42f1eb2328de59be90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Security for wagtail-mptt-comments 0.2.8

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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