Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

django-tree-comments

A Django app for threaded (nested) comments using Common Table Expressions (CTE), ported and extended from django-contrib-comments.

This library is under active development. Version numbers follow the 0.0.x scheme during the experimental stage; SemVer rules will apply once 1.0.0 is reached.

Features

  • Threaded comments — a self-referential parent foreign key models the reply tree (adjacency list, zero redundant tree columns).
  • CTE tree queries — recursive Common Table Expressions fetch an entire comment tree in a single query, with depth and root_id annotations.
  • Multi-backend — works on PostgreSQL, MySQL, and SQLite.
  • Swappable models & forms — customize Comment, CommentFlag, and the form class via TREE_COMMENTS_COMMENT_MODEL, TREE_COMMENTS_COMMENT_FLAG_MODEL, and TREE_COMMENTS_COMMENT_FORM.
  • Class-based views with JSON / HTML-fragment responses — friendly to AJAX and HTMX-style partial rendering.
  • Moderation, flagging, RSS feeds, Django admin integration — full feature parity with django-contrib-comments.
  • Internationalization — ships .po catalogs for 70+ languages.

Requirements

Installation

pip install django-tree-comments

Add tree_comments and django.contrib.sites to your INSTALLED_APPS:

INSTALLED_APPS = [
    ...
    "django.contrib.sites",
    "tree_comments",
]

Run the migrations:

python manage.py migrate

Quick start

Render a whole threaded comment app (list + reply form) for any object with a single template tag:

{% load tree_comments %}

{% render_comment_app for article %}

Each comment in the tree carries an annotated depth (and root_id), so templates can indent replies without extra queries:

<div class="comment{% if comment.depth %} is-child{% endif %}">
    {{ comment.comment }}
    <a href="{{ comment.get_reply_url }}">Reply</a>
</div>

See the Quick Start guide for the full walkthrough.

Example projects

Two runnable example projects live under examples/:

Documentation

Full documentation is at django-tree-comments.readthedocs.io, including:

  • Settings — configuration options (TREE_COMMENTS_* settings).
  • Models — the parent field, CTE query methods (cte_for_instance, threaded_for_instance).
  • Custom apps — swappable models & forms.

License

BSD-3-Clause, see LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_tree_comments-0.0.4rc1.tar.gz (142.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_tree_comments-0.0.4rc1-py3-none-any.whl (394.0 kB view details)

Uploaded Python 3

File details

Details for the file django_tree_comments-0.0.4rc1.tar.gz.

File metadata

  • Download URL: django_tree_comments-0.0.4rc1.tar.gz
  • Upload date:
  • Size: 142.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for django_tree_comments-0.0.4rc1.tar.gz
Algorithm Hash digest
SHA256 a0df7ae73d687239fdc8f74e35a1bc69ce898f1632a6bf67f4db527772c43787
MD5 a7f7dedc2f527925be4a36eb63ec923b
BLAKE2b-256 b4fbfa3a4b2731472442f50b18c73acde5dc7931fd6581c4e55fb35310afa61f

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_tree_comments-0.0.4rc1.tar.gz:

Publisher: release.yml on jukanntenn/django-tree-comments

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_tree_comments-0.0.4rc1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_tree_comments-0.0.4rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 078811f878146b1ab0c75c17b1a0cae914573701e6725f1b6cacf907f6c454f7
MD5 4af45e84e3ef47da0e49944a8772a07d
BLAKE2b-256 230d844b63721f3f1703062803e62c8f5448923e588d92dab738e2d334c2edc3

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_tree_comments-0.0.4rc1-py3-none-any.whl:

Publisher: release.yml on jukanntenn/django-tree-comments

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.0.4rc1 This release

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

0.0.0

2 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