Built-in template filter "Safe"

Hello everyone,
I’m new here and have just taken over a Django project. But I must confess that I am an absolute newbie. I have a problem. I have an email template subject that looks like this:

IT Severity {% if case.severity == "low" %}4{% endif %}{% if case.severity == "medium" %}3{% endif %}{% if case.severity == "high" %}2{% endif %}{% if case.severity == "critical" %}1{% endif %} - {% if case.caseupdate_set.first.update_state == "solved" %}{% if case.caseupdate_set.all|length < 2 %}Directly {% endif %}{% endif %}{{ case.caseupdate_set.first.update_state|upper }} - {{ case.reference_number }} [{{  case.title  }}]

In the Case.title the following characters are used from time to time:

< is converted to &lt;
> is converted to &gt;
' (single quote) is converted to &#x27;
" (double quote) is converted to &quot;
& is converted to &amp;

I was told that I could work around this with the tag “safe”. Unfortunately, I have no idea where to insert this tag. Can you help me?

Side note: When posting code or templates here, post the code between lines of three backtick - ` characters. This means you’ll have a line of ```, then the code (or template), then another line of ```. This forces the forum software to keep the code properly formatted. (I’ve taken the liberty of editing your original post.)

1 Like

It’s not a tag, it’s a filter. See the docs for the safe filter

Ok, but where do I have to add this filter in my template?

What does the example of its usage in the docs suggest?

Got it! Sometimes you can’t see the wood for the trees FACEPALM

Thanks :slight_smile: