<p>In my django application I am using a template to construct email body, one of the parameters is url, note there are two parametes separated by ampersand in the url.</p>

<pre><code>t = loader.get_template("sometemplate")
c = Context({
   'foo': 'bar',
   'url': 'http://127.0.0.1/test?a=1&amp;b=2',
})
print t.render(c)
</code></pre>

<p>After rendering it produces: <code>http://127.0.0.1/test?a=1&amp;amp;amp;b=2</code></p>

<p>Note the ampersand is HTML encoded as "&amp;amp;". One way around the problem is to pass each parameter separately to my template and construct the url in the template, however I'd like to avoid doing that.</p>

<p>Is there a way to disable HTML encoding of context parameters or at the very least avoid encoding of ampersands?</p>

To turn it off for a single variable, use
```
mark_safe
```
:
```
```
from django.utils.safestring import mark_safe

t = loader.get_template("sometemplate")
c = Context({
   'foo': 'bar',
   'url': mark_safe('http://127.0.0.1/test?a=1&b=2'),
})
print t.render(c)
```
```
Alternatively, to totally turn autoescaping off from your Python code,
use the
```
autoescape
```
argument when initialising a
```
Context
```
:
```
```
c = Context({
   'foo': 'bar',
   'url': 'http://127.0.0.1/test?a=1&b=2',
}, autoescape=False)
```
```
The
How to turn [Automatic HTML escaping] off
section of the documentation covers some of the in-template options if you'd rather do it there.