I fixed doing this
{% autoescape off %}
{{ my_var_with_& }}
{% endautoescape%}
now works fine.
On Thursday, May 21, 2015 at 11:53:07 AM UTC-5, Andréas Kühne wrote:
>
> 2015-05-21 18:35 GMT+02:00 dk <[email protected] <javascript:>>:
>
>> I am creating a string inside the view that will be use in the template
>> on the javascript.
>> my string in python contains & and I print the view and works fine,
>> but when is send to the template I don get &.
>>
>> is there something magical about & ? or any hint on how to make it
>> work? thanks guys.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected]
>> <javascript:>.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/a432f1b0-5042-4b4a-a7ff-57e92ce539be%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/django-users/a432f1b0-5042-4b4a-a7ff-57e92ce539be%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> Yes & is & when it is HTML encoded. You will get the same problem if
> you try to send "<b>Bold text</b>" to a template, it will become the HTML
> equivalent. All strings sent from your view function / class to the
> template will be HTML encoded UNLESS you use safestring strings:
> https://docs.djangoproject.com/en/1.8/ref/utils/#module-django.utils.safestring
>
> Regards,
>
> Andréas
>
>
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/6ee49346-f842-4880-a118-72bf8de2608d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.