I’m trying to implement tree-like comments for my django projects. Each comment can be replied and is saved as given comment child.
comment 1
|- reply 1 to comment 1
|- reply 2 to comment 1
|- reply 3 to comment 1
|- reply 1 to reply 3 to comment 1
|- reply 2 to reply 3 to comment 1
comment 2
|- reply 1 to comment 2
... and so on ...
Here is my model:
class Comment(models.Model):
author = models.ForeignKey(User)
parent = models.ForeignKey(Comment, blank=True) #
text = models.TextField()
created = models.DateTimeField()
updated = models.DateTimeField(blank=True)
Is this the way to go, or am I reinventing the wheel? I’m sure that this is typical enough case so there are built in solutions for something like that? Thank you.
Those are called threaded comments. It’s not built in, but here’s an app for that which you could
https://github.com/ericflo/django-threadedcomments