I'm creating a "Polls" like application. In this application there will be questions and every question will have single or multiple answers choices. The answer choice can be Text, Image, or Video.
I have made one model called Question and different models for different choice types:
class Question(models.Model):
question_text = models.TextField()
category = models.ForeignKey(QuestionCategory)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
class ChoiceText(models.Model):
question = models.ForeignKey(Question, on_delete=models.CASCADE)
choice = models.CharField(max_length=255)
class ChoiceImage(models.Model):
question = models.ForeignKey(Question, on_delete=models.CASCADE)
choice = models.ImageField()
- Is this a good way to design the models, or is there a better way to solve this problem ?
- It doesn't look so intuitive in the admin side too, any suggestions on the admin side ? I looked at https://docs.djangoproject.com/en/2.1/intro/tutorial07/ but I'm still confused about combining the different choices into a better user-friendly way.