Note that there are some explanatory texts on larger screens.

plurals
  1. POdjango unicode convert to japanese
    primarykey
    data
    text
    <p>I create one table member, which contains one field 'name' which need to store Japanese. I use web service to visit the table data. Below is the code,</p> <pre><code>from django.http import HttpResponse from rest_framework.renderers import JSONRenderer class JSONResponse(HttpResponse): """ An HttpResponse that renders it's content into JSON. """ def __init__(self, data, **kwargs): content = JSONRenderer().render(data) kwargs['content_type'] = 'application/json' super(JSONResponse, self).__init__(content, **kwargs) from rest_framework import serializers class MemberSerializer(serializers.ModelSerializer): class Meta: model = Member fields = ('member_id', 'name', 'homepage', 'map') def restore_object(self, attrs, instance=None): """ Create or update a new Member instance, given a dictionary of deserialized field values. Note that if we don't define this method, then deserializing data will simply return a dictionary of items. """ if instance: # Update existing instance instance.member_id = attrs.get('member_id', instance.member_id) instance.name = attrs.get('name', instance.name) instance.homepage = attrs.get('homepage', instance.homepage) instance.map = attrs.get('map', instance.map) return instance # Create new instance return Member(**attrs) //snapshot code serializer = MemberSerializer(member) return JSONResponse(serializer.data) </code></pre> <p>The 'name' value displays as unicode , {"name": "\u691c\u8a3a\u3092\u4e88\u7d04\u3059\u308b"}. How can I convert it to Japanese?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload