Forums

Flask template code not updating

I have a very simple Flask App with one view. When I make changes to the view in the editor they are not reflected when I run the web app, however if I change a python file those changes take effect. I have tried restarting the web app to no avail, even deleting the view file and restarting the app has no effect, the view is still rendered. It's as if it is cached somewhere.

I have checked all the paths and files, I definitely only have one view file and it is referenced correctly by the route, this is not a case of a duplicate view being referenced.

I would say I am an intermediate Flask user so I would hope that I have not made a n00b error, though I may well have done!

Very weird, any advice is appreciated.

Furthermore, if I create a new view and change the route to reference that view the web app crashes with a TemplateNotFound error.

If I make a new route and a new template that also doesn't work, throwing the TemplateNotFound error. For some reason any changes in my template folder do not take effect

Just to clarify, what do you mean that you can change a python file to get the changes to take effect?

You definitely need to restart the webapp (by clicking the reload button) for any changes to take effect.

Hi bfg,

I mean that if I edit a .py file with code to say print to the console that works fine but if I edit a .html template changes to that file do not take effect.

I am definitely restarting the web app :)

OK it was a n00b error. When I created my project structure I put the template folder one level up from where it should have been. I recloned the project and got a template not found error which highlighted that fact, odd that that one template was rendering even though it was in the wrong folder!

hmm- do you know if that .html template change ever takes effect eventually? also- could it be that you are making changes to cached js files etc that are cached in your browser locally?

I have the same problem. In files my template was changed successfully on pulling from github. But when I visit my app the old version of the template is loaded. I tried: - reload app a couple of times, disable app and enable again - not helped - clean cash - not helped - visit from another device - not helped

Check that the files have actually been changed and that they are the ones that your web app is actually using.