I used it to escape a rendered form in an ajax response to load it afterwards into a wrapper element with javascript. I currently decode it as UTF-8, but I guess supporting a safe string would be more intuitive.

I used it to escape a rendered form in an ajax response to load it afterwards into a wrapper element with javascript. I currently decode it as UTF-8, but I guess supporting a safe string would be more intuitive.

Use django.template.defaultfilters.escapejs instead of javascript_quote. (You don't need to limit use of template filters to template rendering. Filters are just functions that operate on strings, and safe strings.)