Created
February 8, 2012 13:05
-
-
Save camilonova/1769238 to your computer and use it in GitHub Desktop.
Comment tree model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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