[Fixed]-Django seems to escape HTML characters (but is not supposed to)

1👍

OK, thanks to Bestasttung’s comment, I solved my problem with this:

{% autoescape off %}
<p>{% i18n 'Foobar' %}</p>
{% endautoescape %}

But that wasn’t very satisfying since I had multiple templates to update.
So, I simply changed my i18n method from:

def i18n(context, key):
    ...
    return s

to:

def i18n(context, key):
    ...
    return mark_safe(s)

I hope that will help someone facing the same issue.

Leave a comment