{% for var in custom_html_panel.variables.all %} {% if var.active and var.device.active %} {% endif %} {% endfor %} {{ custom_html_panel.html|safe }}