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.xscheme during the experimental stage; SemVer rules will apply once1.0.0is reached.
Features
- Threaded comments — a self-referential
parentforeign 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
depthandroot_idannotations. - Multi-backend — works on PostgreSQL, MySQL, and SQLite.
- Swappable models & forms — customize
Comment,CommentFlag, and the form class viaTREE_COMMENTS_COMMENT_MODEL,TREE_COMMENTS_COMMENT_FLAG_MODEL, andTREE_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
.pocatalogs for 70+ languages.
Requirements
- Python 3.10+
- Django 5.2+
- django-cte
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/:
examples/default— the defaulttree_comments.Commentmodel.examples/custom— a custom swappable comment model and templates.
Documentation
Full documentation is at django-tree-comments.readthedocs.io, including:
- Settings — configuration
options (
TREE_COMMENTS_*settings). - Models — the
parentfield, 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a0df7ae73d687239fdc8f74e35a1bc69ce898f1632a6bf67f4db527772c43787
|
|
| MD5 |
a7f7dedc2f527925be4a36eb63ec923b
|
|
| BLAKE2b-256 |
b4fbfa3a4b2731472442f50b18c73acde5dc7931fd6581c4e55fb35310afa61f
|
Provenance
The following attestation bundles were made for django_tree_comments-0.0.4rc1.tar.gz:
Publisher:
release.yml on jukanntenn/django-tree-comments
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_tree_comments-0.0.4rc1.tar.gz -
Subject digest:
a0df7ae73d687239fdc8f74e35a1bc69ce898f1632a6bf67f4db527772c43787 - Sigstore transparency entry: 2321197356
- Sigstore integration time:
-
Permalink:
jukanntenn/django-tree-comments@c928f84f40b42732961fec953c2a52d0cbfaf521 -
Branch / Tag:
refs/tags/v0.0.4rc1 - Owner: https://github.com/jukanntenn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c928f84f40b42732961fec953c2a52d0cbfaf521 -
Trigger Event:
push
-
Statement type:
File details
Details for the file django_tree_comments-0.0.4rc1-py3-none-any.whl.
File metadata
- Download URL: django_tree_comments-0.0.4rc1-py3-none-any.whl
- Upload date:
- Size: 394.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
078811f878146b1ab0c75c17b1a0cae914573701e6725f1b6cacf907f6c454f7
|
|
| MD5 |
4af45e84e3ef47da0e49944a8772a07d
|
|
| BLAKE2b-256 |
230d844b63721f3f1703062803e62c8f5448923e588d92dab738e2d334c2edc3
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_tree_comments-0.0.4rc1-py3-none-any.whl -
Subject digest:
078811f878146b1ab0c75c17b1a0cae914573701e6725f1b6cacf907f6c454f7 - Sigstore transparency entry: 2321197400
- Sigstore integration time:
-
Permalink:
jukanntenn/django-tree-comments@c928f84f40b42732961fec953c2a52d0cbfaf521 -
Branch / Tag:
refs/tags/v0.0.4rc1 - Owner: https://github.com/jukanntenn
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c928f84f40b42732961fec953c2a52d0cbfaf521 -
Trigger Event:
push
-
Statement type: