I am creating a web site in google app engine using python. Unfortunately, I could not find anything concerning my problem. I have to distinguish a variable according to its content.
For example i am going to send variables like this
content = {
'mail':session.get('user_mail',''),
'role':'Admin',
}
render_template(self, 'index.html', content)
And i need such kind of code to understand the type of user if it is a 'Login' user or 'Admin' user.
{% if role == 'Ordinary' %}
{{ role }}
{% elif role == 'Admin' %}
{{ role }}
{% endif %}
How can i do this?
Or maybe there is better design that you can suggest me.
Thank you...
There is no elif
in django templates. Use something like this:
{% if role == 'Login' %}
... stuff
{% else %}{% if role eq 'Admin' %}
... stuff
{% endif %}
Or, with ifequal
:
{% ifequal role "Login" %}
... stuff
{% else %}{% ifequal role "Admin" %}
... stuff
{% endifequal %}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With