0

I have been trying to implementing my code for Index and index.html. My code for Index seems to work very well, but my index.html isn't. The jinja template is pasted below. For some reasons, the table is printed perfectly, as well as the table headers and the user's current cash balance and total asset, with the exception that all rows inside the for loop simply do not show up. Any advice why? Thank you very much and I appreciate any help!!!

{% extends "layout.html" %}

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

{% block main %}

    <table border="1">
        <tr>
            <th>Stocks</th>
            <th>Total Shares</th>
            <th>Current Prices</th>
        </tr>

        {% for stock in stocks %}

        <tr>
            <td>{{stock.stock}}</td>
            <td>{{stock.total_shares}}</td>
            <td>{{stock.lookup(stock["stock"])["price"]}}</td>
        </tr>

        {% endfor %}

        <tr>
            <td></td>
            <td></td>
            <td>Your Current Cash Balance: ${{cash}}</td>
        </tr>

        <tr>
            <td></td>
            <td></td>
            <td>Your Total Asset: ${{total_worth}}</td>
        </tr>

    </table>

{% endblock %}
1

lookup() in helpers.py is not available to jinja. It should be called in index. But that would give a big fat exception. Suspect index is sending an empty list to stocks argument.

1
  • It is not just about lookup() because all three rows, and not just the <td>{{stock.lookup(stock["stock"])["price"]}}</td>, inside the for loop are not showing up (I appreciate that piece of your advice though and will call the function in index instead) @DinoCoderSaurus
    – Alex Chan
    May 2 '17 at 4:29

You must log in to answer this question.

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