1. Adam Knight
  2. milton


milton / comments / models.py

from django.db import models
from django.contrib.comments.models import Comment
from mptt.models import MPTTModel, TreeForeignKey

### COMMENTS ###

class MPTTComment(MPTTModel, Comment):
    """ Threaded comments - Add support for the parent comment store and MPTT traversal"""
    # a link to comment that is being replied, if one exists
    parent = TreeForeignKey('self', null=True, blank=True, related_name='children')
    title = models.CharField(max_length=200, null=True, blank=True)

    class MPTTMeta:
        # comments on one level will be ordered by date of creation

    class Meta:

    def depth(self):
        return self.get_ancestors().count()