[Answered ]-Django simple template tag with "if"

2👍

I wonder if you could do this way. The if statement looks for variable show_language_choice_dropdown_menu and probably there is no such variable. Try using assignment tag instead:

@register.assignment_tag
def show_language_choice_dropdown_menu_tag():
  return SHOW_LANGUAGE_CHOICE_DROPDOWN_MENU

and then use it as following:

{% show_language_choice_dropdown_menu_tag as show_language_choice_dropdown_menu %}
{% if show_language_choice_dropdown_menu %}

For more information please refer to https://docs.djangoproject.com/en/1.8/howto/custom-template-tags/#assignment-tags

👤Adrian

Leave a comment