Display data ForeignKey

Hello, I have a question, I would like to display data linked to other data by ForeingnKey in my html template

here is my code

html

  {% for items in quest %}
  <div class="tab"><h1>{{items.namequestion}} <br> {{items.coef}}</h1>
    <fieldset>
      {% for itemscritere in critereQuest %}
        <div class='radiodiv'>
          <input type="radio"  name="{{items.numquestion}}" value="{{itemscritere.notationCritere}}" checked>{{itemscritere.namecritere}} : {{itemscritere.notationCritere}}
        </div>
        {% endfor %}
    </fieldset>
  </div>
  {% endfor %}

models.py

class question(models.Model):
    numquestion = models.CharField(max_length=255,null=True)
    namequestion = models.CharField(max_length=255, blank=True,null=True)
    coef = models.IntegerField()

class critereQuestion(models.Model):
    namecritere = models.CharField(max_length=255, blank=True,null=True)
    notationCritere = models.CharField(max_length=255, blank=True,null=True)
    question = models.ForeignKey(question, on_delete=models.CASCADE, blank=True, null=True, related_name="criterequestions")

views.py

    quest = question.objects.all()
    critereQuest = critereQuestion.objects.all()
    context = { 
        'quest' : quest,
        'critereQuest' : critereQuest
     }

rendering

normaly each “question” has its own criteria and here for each question we have all the criteria

If you are looking for getting all the objects related to a different objects through a reverse ForeignKey, review the work and examples you would have done in the official Django Tutorial in step 2.

You should also read the docs at: