How do I filter possible field values in django admin or at model level for fields linked through nested ForeignKey?

I have the two following models:

class Question(models.Model):
    question_content = models.TextField(max_length=500)

related to:

class PossibleAnswer(models.Model):
    question = models.ForeignKey(Question, on_delete=models.CASCADE)
    answer = models.CharField(max_length=120)

I would like to have a tree structure for a questionnaire, in which the option to go from one question or another might depend on the answer to the previous question. So I wanted to create another model as follows:

class Relation(models.Model):
    child = models.ForeignKey(Question, on_delete=models.CASCADE, related_name="child")
    parent = models.ForeignKey(Question, on_delete=models.CASCADE, related_name="parent")
    parent_answer = models.ForeignKey(PossibleAnswer, on_delete=models.CASCADE, related_name="parent_answer")

Now the issue I have, is that in the django admin, when selecting through parent_answer, it gives me the possibility to select any answer. That is, not only the ones that are linked to the selected parent question (via a foreign key).

I believe that the admin does not do dynamic filtering, but I would at least like the possibility to select on parent_answer is filtered once the parent question has been selected and the record saved. Or that this would somehow be enforced at the model level.

Is this possible?

Any help highly appreciated!

Back to Top