2015-05-21 18:35 GMT+02:00 dk <[email protected]>:

> 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 &amp.
>
> 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].
> 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/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 &amp; 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/CALXYUbkWtEDzmn4GjD0puhanC10Q9Wq0JoESd%3D71cNGuG7%3DWfw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to