12 Ноя 17:45 Admin
class Comment(models.Model):
post = models.ForeignKey(Post,
on_delete=models.CASCADE, related_name='comments')
owner = models.ForeignKey(
Profile, null=True, blank=True, on_delete=models.CASCADE)
text = models.TextField()
published = models.DateTimeField(auto_now_add=True)
approved = models.BooleanField(default=False)
class Meta:
ordering = ['-published']
verbose_name = 'Комментарий'
verbose_name_plural = 'Комментарии'
def approve(self):
self.approved = True
self.save()
def __str__(self):
return self.text