Y
Y
YelKa2022-04-06 08:06:08
Python
YelKa, 2022-04-06 08:06:08

How to add a variable available on all pages of the site?

For example, there is the add_template_global decorator, which adds a function that is available on all pages. How can you add the same variable?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ramis, 2022-04-06
@YelKa

Context processors

@app.context_processor
def inject_user():
    return dict(user='Это я')

HTML
<p>{{ user }}</p>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question