Multi-thread conversation in django (like Reddit)

Posted by dotty on Stack Overflow See other posts from Stack Overflow or by dotty
Published on 2010-05-28T13:37:27Z Indexed on 2010/05/28 13:42 UTC
Read the original article Hit count: 316

Filed under:
|
|

Hay,

i have an app which essentially a conversation system (much like reddits)

Where a post can have multiple replies, and a reply and have multiplies, and a reply to a reply can have multiple replies (etc)

I've made the model like this

class Discussion(models.Model):
    message = models.TextField()
    replies = models.ManyToManyField('self')

and the view

discussions = Discussions.objects.all()

and the template looks like this

{% for discussion in discussions %}
    {{ discussion.message }}
{% endfor %}

How would i go about making a system where i can output all replies like this

discussion
    reply
        reply
    reply
        reply
            reply
                reply

Which would go down as far as it needs to to ensure all replies are listed.

Thanks

© Stack Overflow or respective owner

Related posts about django

Related posts about model