Skip to content

Commit

Permalink
ft:comment model -- add comment fields
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianMwevi committed Jun 16, 2022
1 parent eec4910 commit 503cdb0
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions posts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from django.contrib.auth.models import User
from neighborhoods.models import Neighborhood

# Create your models here.


class Post(models.Model):
user = models.ForeignKey(
Expand All @@ -16,3 +18,19 @@ class Post(models.Model):

def __str__(self):
return self.post


class Comment(models.Model):
user = models.ForeignKey(
User, on_delete=models.CASCADE)
post = models.ForeignKey(
Post, on_delete=models.SET_NULL, null=True)
comment = models.TextField()
likes = models.ManyToManyField(
User, blank=True, related_name='comment_likes')
posted_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)

def __str__(self):
return self.comment

0 comments on commit 503cdb0

Please sign in to comment.