Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Question(models.Model):
- TYPES = (('Text Question', 'Text Question'),
- ('Question with one answer', 'Question with one answer'),
- ('Question with many answers', 'Question with many answers'))
- text = models.TextField(max_length = 500)
- poll = models.ForeignKey(Poll, on_delete = models.CASCADE)
- created_at = models.DateTimeField(auto_now = True)
- type = models.CharField(max_length = 30, choices = TYPES, default = 'Text Question')
- owner = models.ForeignKey(User, on_delete = models.CASCADE)
- def __str__(self):
- return f'Who Asked: {self.owner} | Poll: {self.poll} | Question Types: {self.type}'
- class Answer(models.Model):
- question = models.ForeignKey(Question, on_delete = models.DO_NOTHING)
- choice = models.ManyToManyField(Choice, related_name = 'choices_to_choose', blank = True)
- choice_one = models.ForeignKey(Choice, related_name = 'choice_to_choose', blank = True, on_delete = models.CASCADE)
- text = models.TextField(max_length = 2000, blank = True)
- created_at = models.DateTimeField(auto_now = True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement