from django.db import models
class Blog(models.Model):
    title = models.CharField(max_length=200)
    pub_date = models.DateTimeField('date published')
    body = models.TextField()

    def __str__(self):
        return self.title

    def summary(self):
          return self.body[:100]
# Create your models here.
class Comment(models.Model):
    post= models.ForeignKey(Blog,related_name='comments',on_delete=models.CASCADE)
    author= models.CharField(max_length=10)
    text= models.TextField()
    created_at= models.DateTimeField(auto_now_add=True)
    update_at= models.DateTimeField(auto_now=True)

    def approve(self):
        self.approved_comment=True
        self.save()

    def __str__(self):
        return self.text

