Skip to content

Instantly share code, notes, and snippets.

@camilonova
Created February 8, 2012 13:05
Show Gist options
  • Save camilonova/1769238 to your computer and use it in GitHub Desktop.
Save camilonova/1769238 to your computer and use it in GitHub Desktop.
Comment tree model
class Comment(models.Model):
"""
Representa los comentarios a los posts del blog
"""
post = models.ForeignKey(
'blog.Post',
)
user = models.ForeignKey(
'auth.User',
)
comment = models.TextField(
verbose_name="Comentario",
)
created_at = models.DateTimeField(
auto_now_add=True,
)
parent = models.ForeignKey(
'blog.Comment',
null=True,
blank=True,
related_name='children',
)
def __unicode__(self):
return u'{0}'.format(self.comment)
class Meta:
ordering = ['-created_at']
verbose_name = 'Comentario'
verbose_name_plural = 'Comentarios'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment