I'm creating a quiz app for my project. Each quiz can have multiple questions and each question has multiple answers from which one is correct.
The problem is that Django doesn't allow OneToMany
relationship so I have to use ForeignKey
in models.
class Language_Quiz(models.Model):
name = models.CharField(max_length=40)
language = models.OneToOneField(sfl_models.Language)
class Question(models.Model):
language_quiz = models.ForeignKey(Language_Quiz)
text = models.TextField()
class Answer(models.Model):
question = models.ForeignKey(Question, related_name='answers')
text = models.TextField()
correct = models.BooleanField()
What I want to do is - Django admin would show list of Questions assigned to current Quiz with ability to add or modify them so admin can add questions while creating a Quiz.
Could you give me a hint? It should be something with admin.py