[Fixed]-Conditionally change django template variable

1👍

You can’t do that in Django template language. You could potentially write a tag, but I don’t see why you would want to; you can just do the whole thing inline.

<div class="{% if request.user == item.field1 %}field1{% endif %} {% if request.user == item.field2 %}field2{% endif %}"></div>

Leave a comment