Commit fca54638 authored by Titia de Castro's avatar Titia de Castro

created reaction model in announcements app

parent 689eb431
......@@ -4,4 +4,17 @@ from django.db import models
class Announcement(models.Model):
announcement_title = models.CharField(max_length=200)
announcement_body = models.TextField()
pub_date = models.DateField(auto_now_add=True)
\ No newline at end of file
pub_date = models.DateField(auto_now_add=True)
class Reaction(models.Model):
class ReactionNames(models.TextChoices):
LIKE = 'Like'
LOVE = 'Love'
ANGRY = 'Angry'
reaction_name = models.CharField(max_length=5, choices=ReactionNames.choices)
tally = models.IntegerField(default=0)
announcement = models.ForeignKey(Announcement, on_delete=models.CASCADE, related_name='reactions')
def __str__(self):
return '{} {} reactions'.format(self.announcement.announcement_title, self.reaction_name)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment