A few days back I was messing around with Django, trying to get a feel for how stuff works, when I decided to try and build a simple forum, one that resembled a forum that I frequented (but is now closed down). The idea was that each of the comments would be parent to any number of comments, like so:
comment <--top
comment <-- comment "A"
comment <-- comment "B"
comment <-- comment "C"
comment <--C-1, reply to comment "C"
comment <-- C-1-1, reply to comment "C-1"
comment
comment
comment
comment <-- C-1-1-1 reply to C-1-1
comment
comment
comment
comment
comment
comment
comment
comment
comment
comment
comment
comment
The idea here is that replies to a comment would stuffed one level beneath it, and each comment, with the exception of the very first comment, has a parent. The thing is, although I get the idea behind implementing tree traversals, none of the books/articles I've read on the subject take Django into account (or the MVC pattern for that matter), so my question is how would I go about implementing this system in Django? (here's the model code i've got for reference :-/)
class Comment(models.Model):
Parent = models.OneToOneField('self', null=True)
Children = models.ForeignKey('self', null=True)
Author = models.ForeignKey(User)
Author_IP = models.IPAddressField()
Created_On = models.DateTimeField(auto_now_add=True)
Modified_On = models.DateTimeField(auto_now=True)
Body = models.TextField()