Some data needs to be present in all templates.
How can I transfer the data I need to base.html?
For normal templates I use the render() function.
I do not understand how to apply this for the base template, as it does not get passed into render()
base.html
<html>
<head>
</head>
<header>Your balance: {{ balance }}</header>
<body>
{% block content %}
{% endblock %}
</body>
</html>
views.py
@app.route("/")
def index():
balance = User.query.get(...)
return render_template('index.html',
balance = balance)
@app.route("/settings")
def settings():
balance = User.query.get(...)
return render_template('settings.html',
balance = balance)
@app.route("/exchange")
def exchange():
balance = User.query.get(...)
return render_template('exchange.html',
balance = balance)
etc ..
{{ balance }} - It should be displayed on all pages where this base.html is enabled.
To do this, I need to pass a balance object in each function for each page. How can I make it so that I can only transfer it once for all pages?