On 18 Jan 2014 08:32, "Mario Gudelj" <[email protected]> wrote:
>
> In your template try {{usb_data|safe}}

.......because django escapes everything in the template by default except
you ask not to. One of the methods of doing so if by using the `safe`
filter like Mario suggested.
You can read the documentation on how to escape or unescape stuff in your
template.

>
> On 18/01/2014 4:53 pm, "Igor Korot" <[email protected]> wrote:
>>
>> Hi, ALL,
>> I'd like someone to help me understand this situation.
>> Looking at the page:
https://docs.djangoproject.com/en/dev/topics/serialization/ the part which
says "Serialization formats->JSON" there is an example of how the data
would be serialized.
>> The sample uses the symbol "double quotation".
>>
>> On my machine I have django 1.6.1:
>>
>> C:\Documents and Settings\Igor.FORDANWORK>python
>> Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit
(Intel)] on win32
>> Type "help", "copyright", "credits" or "license" for more information.
>> >>> import django
>> >>> django.get_version()
>> '1.6.1'
>> >>>
>>
>> In my views.py I'm using following code:
>>
>> usb_list = serializers.serialize("json", USB.objects.all())
>> return render_to_response('html/index.html', {"usb_data": usb_list} )
>>
>> where USB is the data model class.
>> This class overrides a __unicode__() function to produce a good output
on the console.
>>
>> Now when I go to the page to see it in the browser I see the data as a
JSON but the data is surrounded with a text "&quot;".
>>
>> So in the docs I see something like this: "abc", while my application
will show: &quot;abc&quot;
>>
>> In the index.html I have this code:
>>
>> <!DOCTYPE html>
>> <html>
>> <head>
>> <title>Test</title>
>> {% load staticfiles %}
>> <script type="text/javascript">
>>     var data = "{{usb_data}}";
>> # some more JavaScript code
>> </script>
>> <html>
>> </html>
>>
>> Is this a recent change? Am I doing something wrong?
>> Thank you.
>>
>>
>> --
>> 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/783144af-8478-408a-bdd5-0b7b5a5a1161%40googlegroups.com
.
>> For more options, visit https://groups.google.com/groups/opt_out.
>
> --
> 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/CAHqTbj%3DO5ysO7cmVXFg8p-aTMbHNZ5gHA4iZ8JaVzNthVjsDkQ%40mail.gmail.com
.
>
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
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/CA%2BWjgXPc0BVPpkkjOij%2BG6otewyksH7Ur7ju%3DH%3DL7%2B8HX8ZVyw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to