Answer the question
In order to leave comments, you need to log in
How to change website directory using Jinja2?
I need to make it so that if a person is not authorized on the site, then he is redirected to another page, how to do this in an HTML file?
The code:
{% if user.is_authenticated %}
<span id='name_of_user'>{{ user.username }}</span>
{% else %}
ЗДЕСЬ НАДО СДЕЛАТЬ ПЕРЕНАПРАВЛЕНИЕ В ДРУГУЮ ДИРЕКТОРИЮ САЙТА
{% endif %}
Answer the question
In order to leave comments, you need to log in
Why such complications?
Isn't it more logical to do it at the server level?
In addition, believe me, if a moderately knowledgeable hacker wants to go to a page that checks authorization using templates, he will go there.
The template should be responsible only for the presentation, there is no place for logic in it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question