Python:
from django.db import models
class Task(models.Model):
title = models.CharField('Название', max_length=50)
task = models.TextField('Описание')
def __str__(self):
return self.title
class Comment(models.Model):
post = models.ForeignKey(Comment,on_delete=models.CASCADE,related_name='comments')
name = models.CharField(max_length=80)
email = models.EmailField()
body = models.TextField()
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
active = models.BooleanField(default=True)
class Meta:
ordering = ('created',)
def __str__(self):
return 'Comment by {} on {}'.format(self.name, self.post)