0

I'm using flask-admin for my dashboard app.

Currently I have the following code in app.py:

@app.route('/', methods=['POST','GET'])
def index():
    cnxn = connection()
    cursor = cnxn.cursor()
    cursor.execute('SELECT DISTINCT Location FROM Table')
    locationlist = cursor.fetchall()
    cnxn.close()
    return redirect(url_for('admin.index'))

And Jinja template with dropdown menu:

<form action="{{ url_for('doc_download') }}" method="POST">
    <label > Location:  </label>
    <SELECT name="location">
      {% for row in locationlist %}
      <option value='{{row.Location}}'>{{row.Location}}</option>
      {% endfor %}
    </SELECT>
    <input type="submit" name="action" value="Download" >
  </form>

How can I pass parameter "locationlist" to the template while maintaining redirect?

I have tried to use render_template instead of redirect for standard data passing, but the existing set up would always tell me that it cannot find template:

url_for('admin.index')

Any suggestions or ideas are appreciated.

curiousdg
  • 1
  • 1

0 Answers0