Answer the question
In order to leave comments, you need to log in
How to use custom Django tags in If-else-endif template constructs?
The bottom line is:
I added my own parameter to the settings.py file:
MY_PARAMETR = True
created a templatetags folder with the __init__.py file and I made a custom tag:
(in the my_tag.py file)
from django import template
from ws.settings import MY_PARAMETR
register = template.Library()
@register.simple_tag
def get_my_parametr():
return MY_PARAMETR
{% load my_tag %}
{% if get_my_parametr %}
{% include "template_true.html" %}
{% else %}
{% include "template_false.html" %}
{% endif %}
{% if get_my_parametr == 'True' %}
{% if get_my_parametr == True %}
<h1>{% get_my_parametr %}</h1>
Answer the question
In order to leave comments, you need to log in
{% get_my_parameter as my_parameter %}
{% if my_parameter %}
...
{% endif %}
from django.conf import settings
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question