Skip to content

Commit a42dc9b

Browse files
committed
Add Comment Model
1 parent e91771d commit a42dc9b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

blog/models.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,19 @@ def get_absolute_url(self):
5151
self.slug
5252
]
5353
)
54+
55+
56+
class Comment(models.Model):
57+
post = models.ForeignKey(Post, on_delete=models.CASCADE, related_name='comments')
58+
name = models.CharField(max_length=80)
59+
email = models.EmailField()
60+
body = models.TextField()
61+
created = models.DateTimeField(auto_now_add=True)
62+
updated = models.DateTimeField(auto_now=True)
63+
active = models.BooleanField(default=True)
64+
65+
class Meta:
66+
ordering = ('created',)
67+
68+
def __str__(self):
69+
return f'Comment by {self.name} on {self.post}'

0 commit comments

Comments
 (0)