i can not get why drop down menu does not work. It seems that the list is empty, but when I check it in another program, it contains information as expected. I just don't get why the dorpdown list is empty. :(

Below is my code:

@app.route("/sell", methods=["GET", "POST"])

def sell():
"""Sell shares of stock."""
currentShList = []
sharesHist = []

#i created list of dicts below to check if drop down would work - and it did
if request.method == "POST":
    #extract list of shares that we owned at some point from database
    sharesHist = db.execute("SELECT sh_symbol, SUM(sh_amount) FROM portfolio GROUP BY sh_symbol")
    #limit list to shares that we own now

    for sh in sharesHist:
        if sh['SUM(sh_amount)']>0:


    return render_template("sell.html", symbolList=currentShList)

my html page is below:

{% extends "layout.html" %}

{% block title %}
    Sell shares owned
{% endblock %}

{% block main %}

    <form action="/sell" method="post">
        <div class="form-group">
            <select class="form-control" name="symbol">
                <option disabled selected value="">Symbol</option>

                {% for symbol in symbolList %}
                    <option value={{symbol["sh_symbol"]}}>{{symbol["sh_symbol"]}}</option>
                {% endfor %}

        <div class="form-group">
            <input autocomplete="off" class="form-control" min="0" name="shares" placeholder="Shares" type="number"/>
        <button class="btn btn-primary" type="submit">Sell</button>

{% endblock %}

1 Answer 1


Just after I posted a question i got it. I should put all data manipulations under else from request.method == "POST".

You must log in to answer this question.

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