Open WillPowellUk opened 2 years ago
First of all, Turbo-Flask is a standard Flask extension. As all extensions, it is initialized with the app instance. You cannot initialize a Flask extension with a Blueprint instance, that just does not work.
My recommendation is that you initialize the turbo extension at the app level, not at the blueprint level, which forces you to import the app instance into the blueprint code. A good place to initialize the extension is in your app factory function.
Your push()
call is indicating that you want to update an element with id="load"
. You don't have any elements in your page with this id
. In fact, you aren't using any ids at all. You are also updating the full page, by pushing the same full-page template that renders the whole page. The idea is that a push updates a section of the page, not the whole page. Please review the load
example in this repository to have a better idea of how this should work.
Thank you very much for your swift and helpful reply!
I was not aware that extensions cannot be initialised with a blueprint instance. After passing in the app instance to myBlueprint and adding the id, I have got this working.
Thank you for all your development with this extension.
After following this tutorial on setting up turbo-flask, I have been unable to get it working with blueprints - I think because of app context.
To initialise turbo, I wanted to write
turbo = Turbo(myBlueprint)
however due to the error'Blueprint' object has no attribute 'config'
I importedapp
and initialised it liketurbo = Turbo(app)
. Then for myupdate_load
function I usedwith app.app_context()
.The
update_load
function does iterate, however the current time on the page does not update without a manual page refresh. Here is the minimal code example, feel free to copy and run it. Any help much appreciated!main.py
init.py
myBlueprint.py
home.html