I want to create variable inside "if" block and call this var in other place
{% for obj in events %}
{% if obj.calendar == instance %}
{% my_var = obj.title %}
<div class="col-md-2">
<div class="thumbnail" data-toggle="modal" data-target="#myModal">
<div class="event_title">{{ obj.title }}</div>
<div class="event_content">{{ obj.content }}</div>
</div>
</div>
{% endif %}
{% endfor %}
obj.calendar == instancein the template context. I.e. place that logic in the view. That will provide the variableobjto the template and make the loop in the template unnecessary. The template syntax will be easier to read.