Use `With` Tag to invert a boolean in Django Template?
问题 I want to pass a value to an include tag that is the OPPOSITE of a variable passed in. This is what I tried (basically): {% with s_options as not disp %} {% include "e.html" with show_options=s_options only %} {% endwith %} Is there any way to do what I want? 回答1: Not sure if this is the best solution, but I just made a new filter: from django import template register = template.Library() @register.filter(name="not_value") def not_value(true_value): return not true_value And then did: {% load