0

The index table looks pretty good, but the "Price" and "Total" columns in the history table are not aligned with the headers. The code for the two is nearly identical.

Here is the code for index.html:

{% extends "layout.html" %}   
{% block title %}
    Your Portfolio
{% endblock %}

{% block main %}

<table class="table table-striped">
    <thead>
        <th>Symbol</th>
        <th>Name</th>
        <th>Shares</th>
        <th>Current Value</th>
        <th>Total Value</th>
    </thead>

    <tbody>
    {% for holding in current_holdings %}
        <tr>
            {%for item in holding%}
            <td>{{ item }}</td>
            {% endfor %}
         <tr>
    {% endfor %}
    </tbody>
</table>

<table class="table table-striped">
    <thead>
        <th>Total Holdings</th>
        <th>Cash on Hand</th>
        <th>Total Worth</th>

    </thead>

    <tbody>
        <tr>
            <td>{{ totals[0] }}</td>
            <td>{{ totals[1] }}</td>
            <td>{{ totals[2] }}</td>

        </tr>
    </tbody>
</table>

{% endblock %} 

... and here is history.html:

{% extends "layout.html" %}

{% block title %}
    Your Transaction History
{% endblock %}

{% block main %}

<table class="table table-striped">
    <thead>
        <th>Date</th>
        <th>Sym</th>
        <th>Bought</th>
        <th>Sold<th>
        <th>Price</th>
        <th>Total</th>
    </thead>

    <tbody>
    {% for trans in transaction_list %}
        <tr>
           {% for item in trans%}
            <td>{{ item }}</td>
           {% endfor %}
        </tr>
    {% endfor %}
    </tbody>
</table>   

{% endblock %}
5
  • Suggest you check your html output (history) with a validator. It will show you the typo right quick. You can right-click, View Source then copy/paste into the textarea of the validator. – DinoCoderSaurus Jun 20 '17 at 17:59
  • I don't get any errors in one that are not present in the other. It particularly hates the for-loop ("Misplaced non-space characters inside a table."), which I think is a Jinja-specific thing. – Patrick Dennis Jun 20 '17 at 19:27
  • I expected it to complain about the missing </th> for 'Sold'. – DinoCoderSaurus Jun 20 '17 at 19:40
  • Ha! You're smarter than the Validator! That did it. Thanks. – Patrick Dennis Jun 20 '17 at 19:45
  • FYI make sure you validate the rendered html, not the template source. The "right-click->View Source" is on the history page in the browser. (or "View page source" in Chrome) – DinoCoderSaurus Jun 21 '17 at 10:22
0

Typo (absent close th) as noted in comments, pointed out by DinoCoderSaurus, who should get any upvotes coming.

You must log in to answer this question.

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