0
{% extends "layout.html" %}

{% block title %}
Index
{% endblock %}

{% block main %}
        <table style="width: 100%">
         <tr>
        <th>Symbol</th>
        <th>Name</th>
        <th>Price</th>
        <th>Shares</th>
        <th>Total</th>
    </tr>
    <ul id=positions>
    <tr>
        {% for symbol, name, price, shares, total in positions %}
        <dt>{{symbol.symbol}}</dt>
        <dt>{{name.name}}</dt>
        <dt>{{price.price}}</dt>
        <dt>{{shares.shares}}</dt>
        <dt>{{total.total}}</dt>
        {% endfor %}
    </tr>
    </ul>
        </table>
{% endblock %}

Please see my code above. I have made a jinja code to display index. The problem I have is that only partital output is given and the table headers are under the output. Could please anyone clear up what I do wrong.

Output for positions is:

[[{'name': 'Alphabet Inc.'}, {'price': 750.5}, {'symbol': 'GOOG'},          {'shares': 1}, {'total': '$750.50'}], [{'name': 'InterXion Holding N.V. Ordinary'}, {'price': 32.63}, {'symbol': 'INXN'}, {'shares': 4}, {'total': '$130.52'}], [{'name': 'St. Joe Company (The) Common St'}, {'price': 20.25}, {'symbol': 'JOE'}, {'shares': 2}, {'total': '$40.50'}], [{'name': 'Royal Dutch Shell PLC Royal Dut'}, {'price': 51.92}, {'symbol': 'RDS-A'}, {'shares': 8}, {'total': '$415.36'}]]
1
  • i think you want to write <td>...</td> there...as in table data
    – shaistha
    Jan 3 '18 at 11:19
1

Have you validated your html? Does it complain about the <dt>...</dt> tags?

From MDN:

The HTML <dt> element (or HTML Description Term Element) identifies a term in a description list. This element can occur only as a child element of a <dl>.

Since you are building table rows, it probably is just a typo.

0

It has to be <td>...</td> not <dt>...</dt>

Hope this helps!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .