I am facing an issue where django's template filters are not working inside a js
script when applied to an object's attribute.
When I use the following code, it results in a js
SyntaxError:
<script>
{{ obj.geometry.geojson | safe }}
</script>
However, if the filter is applied directly on the object itself, no error occurs:
<script>
{{ obj | safe }}
</script>
The content of the GeoJson
file mentioned above is as follows:
{ "type": "Polygon", "coordinates": [ [ [ 3, 36 ], ... }
I need to ensure that the quote character ("
) is not escaped into ("
) so that I can later use JSON.parse()
to convert it from a string to an object.