2

I have a Python Flask application with Flask-SQLAlchemy. when new data gets inserted to the db, it doesn't get fetched unless I restart the server.

view_function

from models import dataObj

@app.route('/view-data/')
def view_data():
    objs = dataObj.query.order_by(dataObj.added_date.desc()).all()
    return render_template("view_data.html", objs=objs)

add_data_function

data_obj = dataObj("data")
db.session.add(data_obj)
db.session.commit()

view_data.html

{% if objs %}
    {% for obj in objs %}
        {{obj.data}}
    {% endfor %}
{%endif%}

Is there some caching in play ?

Michael Yousrie
  • 1,132
  • 2
  • 10
  • 20

0 Answers0