Post and Comment with the same Model.
- by xRobot
I have created a simple project where everyone can create one or more Blog.
I want to use this models for Post and for Comment:
class Post_comment(models.Model):
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField(_('object ID'))
content_object = generic.GenericForeignKey()
# Hierarchy Field
parent = models.ForeignKey('self', null=True, blank=True, default=None, related_name='children')
# User Field
user = models.ForeignKey(User)
# Date Fields
date_submitted = models.DateTimeField(_('date/time submitted'), default = datetime.now)
date_modified = models.DateTimeField(_('date/time modified'), default = datetime.now)
title = models.CharField(_('title'), max_length=60, blank=True, null=True)
post_comment = models.TextField(_('post_comment'))
markup = models.IntegerField(choices=MARKUP_CHOICES, default=DEFAULT_MARKUP, null=True, blank=True)
if it is a comment the parent is not null.
So in most case the text field will contain a little bit of text.
Can I use this model for both Post and Comment ?