I have a button that, when clicked, changes a boolean that corresponds to the jinja2 code, and then reloads the page to update the changes. It looks something like this:
{% if true %}
onclick="<function here that sets it to false>;location.reload()
{% if false %}
onclick="<function here that sets it to true>;location.reload()
{% endif %}
And while the code actually works, as the button does change, it doesn't change with the reload; rather, it requires either clicking the button a second time or manually refreshing the page before it updates. I'm not quite sure why.