django-comments-tree

Django Comments Framework extension app with django-treebeard support, follow up notifications and email confirmations, as well as real-time comments using Firebase for notifications.


Keywords
django, comments, treebeard, threaded, django-channels, websockets
License
MIT
Install
pip install django-comments-tree==0.2.0

Documentation

django-comments-tree TravisCI

A Django pluggable application that adds comments to your project.

https://github.com/sharpertool/django-comments-tree/blob/master/docs/images/cover.png

It extends the once official django-contrib-comments with the following features:

  1. Comments model based on django-treebeard to provide a robust and fast threaded and nested comment structure.
  2. Efficiently associate a comment tree with any model through a link table which avoids populating each comment with extra link data.
  3. Customizable maximum thread level, either for all models or on a per app.model basis.
  4. Optional notifications on follow-up comments via email.
  5. Mute links to allow cancellation of follow-up notifications.
  6. Comment confirmation via email when users are not authenticated.
  7. Comments hit the database only after they have been confirmed.
  8. Registered users can like/dislike comments and can suggest comments removal.
  9. Template tags to list/render the last N comments posted to any given list of app.model pairs.
  10. Emails sent through threads (can be disable to allow other solutions, like a Celery app).
  11. Fully functional JavaScript plugin using ReactJS, jQuery, Bootstrap, Remarkable and MD5.

Example sites and tests work under officially Django supported versions:

  • Django 3.0, 2.2
  • Python 3.8, 3.7

Additional Dependencies:

  • django-contrib-comments >=2.0
  • djangorestframework >=3.8, <3.9

Checkout the Docker image danirus/django-comments-tree-demo.

Read The Docs.

Why Create a New Package

I did not particularly like how the core django-contrib-comments added a GenericForeignKey to each and every comment in order to associate a comment stream with another model. I wanted to have a single place where this association was made.

I opted to add a model just for linking the comments to other models. This model has a single record for a model -> comment-tree association. The record contains the GenericForeignKey, and a single ForeignKey to the comments root node that starts the comments for that model. This is very flexible, and if the underlying model changes, it is a simple matter to move all comments to a new parent. Treebeard just makes all of this work.

Treebeard provides robust mechanisms to get the parent, children, siblings, and any other association you might needed from the comment stream. This also makes it much easier to have a very robust tree structure, so nesting, replies, replies to replies, etc. are easy to handle, and very efficient.

Attribution

This package is a fork of the excellent work at django-comments-xtd

I created the fork because I wanted to a comment tree based on MP_node from django-treebeard. I consider this to be a more robust tree implementation. Treebeard suppports multiple root nodes, so each root node can be an entire comment tree.