0

I'm trying to restrict access to regular users so that a part of my website is only accessible to administrators. I would like the server to render specific content based on the role of the visiting user.

I'm using the Flask framework and a few of its modules. This is what I have:

{% extends 'admin/master.html' %}

{% if True %}

    {% block body %}
        <p>Welcome Admin!</p>
        <a href="/">Back Home</a>
    {% endblock %}

{% else %}

    {% block page_body %}
        <h1>Forbidden!</h1>
    {% endblock page_body %}

{% endif %}

I'm planning to use the if statement to render different content but I was baffled to see the following response:

enter image description here

Has anyone any suggestions on why it is rendering the 'else' block?

This is my requirements.txt:

requests
wtforms
flask
flask_sqlalchemy
flask_wtf
flask-bcrypt
flask-login
Pillow
flask-admin
flask-principal

Thanks for your help!

davidism
  • 121,510
  • 29
  • 395
  • 339
  • Maybe try an actual comparison, what about: `{% if 1 == 1 %}` – admcfajn Apr 17 '20 at 22:27
  • None of the suggestions have worked for me, unfortunately. I'm starting to thing there must be something wrong with the Flask-Admin module. Thanks anyway... – kungfubamba Apr 17 '20 at 23:02

0 Answers0