0
votes

I am not sure how to remove spaces and &amp in the django template variable. Actually I rendered a url string as django variable when I load a page.

But it automatically contains &amp and spaces. After all, in html view, it is showed with &amp, % inside of the variable when I print it out in js console.

Of course, I can fix in js code by replacing them, but code will get messy so I want to another way with python or django code.

any ideas to remove them in server-side?

Result:

http://127.0.0.1:8000/users?key=fff&ids=(1%,3%,4%,12%)

what I expect:

http://127.0.0.1:8000/users?key=fff&ids=(1,3,4,12)
1

1 Answers

1
votes

Assume in your context there is

context['url'] = 'http://127.0.0.1:8000/users?key=fff&ids=(1,3,4,12)'

If you want to get something as is, without any escaping, you can use the safe template tag

{{ url | safe }}