Refreshing causes old values to appear
See original GitHub issueHi,
I’ve been noticing a weird behaviour that we can’t seem to understand how to fix.
Once you edit a field in Flask Admin the values gets correctly saved to the database (I checked) but sometimes when refreshing the Flask Admin UI it displays the old values, seemingly at random.
You can see it in the following screen recording (I’m refreshing a few times).
I’m using Python 3.6.3, Flask 0.12.2, flask-admin 1.5.0 and SQLAlchemy 1.1.15 and flask-sqlalchemy 2.3.2
It seems like it’s not correctly refreshing the session.
I’ve even tried with the following but to no avail:
from flask_admin.contrib.sqla import ModelView
class BaseView(ModelView):
def after_model_change(self, form, model, is_created):
self.session.expire_all()
self.session.remove()
How can I fix it?
Thank you
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Hooks useCallback keeps using old values when ...
So whats happening here is that the useCallback is closing over the state variables for that particular render, So the console.log even after...
Read more >Solved: Gallery refresh overwrites old values in gallery - Page 3
Solved: Hi I need help to stop the gallery overwrite old values when a patch occurs on the textbox placed in the gallery....
Read more >How to update old content to boost your traffic
3 reasons to include content refreshing in your content marketing strategy ... Old URLs have a lot of value because they've accumulated ...
Read more >Local Variables - Appian 22.4
localVariables function refresh when a referenced variable in the value configuration changes. You can change these refresh behaviors using the a!
Read more >Refresh Extracts - Tableau
Note: You can also automate extract refreshes using the Tableau Data ... you will be unable to open the extract with previous versions...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
After googling, reading http://docs.sqlalchemy.org/en/latest/orm/contextual.html, https://github.com/mitsuhiko/flask-sqlalchemy/issues/99 and http://flask.pocoo.org/docs/0.12/reqcontext/#callbacks-and-errors
I ended up with the following, expiring the session and removing it after each request.
Keep in mind I’m not using threading, just gunicorn with two processes.
where db is my SQLAlchemy object in Flask.
I’m not sure why it isn’t the default but it is working.
Ran into this today and @rhymes fix worked. flask==2.2.2 flask-admin==1.6.0 flask-sqlalchemy==2.5.1 sqlalchemy==1.4.41