0

I encounter a small issue about filling my html array in a django template.

I wanted to print one form to one row. Instead of one row to all forms ( that's what i get with the sample code just right there ) :

 <thead> <!-- cétait td à la place de th -->
            <tr>
            {% for entry in headers %}
            <th>
            {{ entry }}
            </th>
            {% endfor %}
            </tr>             

          </thead>
          <tbody>

                <tr>
                {%for entry in entries%}
                {%for cle, valeur in entry.all_form_entry_json%}
                {%for key, valor in headersLoop%}
                {%if key == cle%}

                 <td> {{valeur}}</td>


                {% endif %}

                {% endif %}
                {% endfor %}
                {% endfor %}                   
                {% endfor %}                    
                </tr>

          </tbody> 

The result is such as follow :

enter image description here

You can notice that all the datas are printed to the right corner and go beyond the array limit.

How can i have a result like this ?

enter image description here

Is this possible to do it only with html ? Or should i create a js or css file and import it to this template.html ?

Thank you for your answers !

1 Answer 1

3

I think you just wrong place for the html <tr> tag, the tag <tr> should inside {% for loop..

<thead>
  <tr>
  {% for entry in headers %}
    <th>{{ entry }}</th>
  {% endfor %}
  </tr>
</thead>

<tbody>
{% for entry in entries %}
  <tr>
    {% for cle, valeur in entry.all_form_entry_json %}
      {% for key, valor in headersLoop %}
        {% if key == cle %}
          <td>{{ valeur }}</td>
        {% endif %}
      {% endfor %}
    {% endfor %}
  </tr>
{% endfor %}
</tbody>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.