I have an application that has several partial templates that are loaded as needed by the business rules. In one of these templates, it receives context variables from views.py.
One of these variables, called ‘html_code’, contains HTML code returned from the database with specific form fields that are dynamically defined by the user.
Within this variable, the HTML code has a template tag that needs to call another variable received from the context, ‘random_id’, but it is not being processed and is displayed exactly as it is in the HTML obtained from the database.
Template:
{% if html %}
<!-- Custom client information goes here -->
<div class="row">
<div class="col-md-12">
<h4 class="header-title mb-3 pt-2 text-dark d-flex align-items-center">
Custom info.
</h4>
</div>
</div>
{{ html_code|safe }}
{% endif %}
The html code (html_code) obtained from context (views.py):
<div class="row">
<div class="col-md-12 mb-3">
<label class="form-label">Shipping Company</label>
<input type="text" class="form-control" name="shipping_company[{{random_id}}]">
</div>
</div>
What is being rendered when i test
(look to {{random_id}} not rendered properly)
<div class="row">
<div class="col-md-12 mb-3">
<label class="form-label">Transportadora</label>
<input type="text" class="form-control" name="shipping_company[{{random_id}}]">
</div>
</div>
What i expect:
<div class="row">
<div class="col-md-12 mb-3">
<label class="form-label">Transportadora</label>
<input type="text" class="form-control" name="shipping_company[{{NDFISOGFDOUF}}]">
</div>
</div>
How can I make the template tags returned from the context be processed in the template?