Re: Django queryset csv encode

2014-05-26 Thread hito koto
Hi, WongoBongo, Thanks 2014年5月26日月曜日 18時39分20秒 UTC+9 WongoBongo: > > If you want all the user_name's in Staff as UTF-8: > > staff = Staff.objects.all() > staff_list = [s.user_name.encode('utf-8') for s in staff] > > I'm not familiar with the encoding you mentioned in your last message. Try > i

Re: Django queryset csv encode

2014-05-26 Thread Kelvin Wong
If you want all the user_name's in Staff as UTF-8: staff = Staff.objects.all() staff_list = [s.user_name.encode('utf-8') for s in staff] I'm not familiar with the encoding you mentioned in your last message. Try it. K On Monday, May 26, 2014 2:12:14 AM UTC-7, hito koto wrote: > > Hi, > > this

Re: Django queryset csv encode

2014-05-26 Thread Kelvin Wong
Okay, I re-read your first post. You said that you wanted to get a UTF-8 string. name = [name.encode("utf8") for name in Staff.objects.filter(id = 3).values_list('user_name', flat=True)] This variable 'name' now contains a UTF-8 encoded string in a list-like object. Python 2.7.6 (default, Jan

Re: Django queryset csv encode

2014-05-25 Thread hito koto
Hi, I have this: >>> x = name >>> import locale >>> locale.getdefaultlocale()[1] 'UTF8' >>> print x ['\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf'] after i try this : >>> name ['\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf'] >>> type(name) Traceback (most recent call last): File "",

Re: Django queryset csv encode

2014-05-25 Thread WongoBongo
Python 2.7.6 (default, Jan 13 2014, 04:26:18) [GCC 4.2.1 (Apple Inc. build 5577)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> x = u'\u54c8\u65af\u671d\u9b6f' >>> print(x) 哈斯朝魯 >>> import locale >>> locale.getdefaultlocale()[1] 'UTF-8' >>> K On Sunday, May

Re: Django queryset csv encode

2014-05-25 Thread hito koto
Hi, I'm try tha's but results: >>> b'\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf'.decode('utf8') u'\u54c8\u65af\u671d\u9b6f' 2014年5月26日月曜日 14時10分44秒 UTC+9 WongoBongo: > > Python 3.4.0 (default, Mar 20 2014, 12:50:31) > [GCC 4.0.1 (Apple Inc. build 5493)] on darwin > Type "help", "copyri

Re: Django queryset csv encode

2014-05-25 Thread Kelvin Wong
Python 3.4.0 (default, Mar 20 2014, 12:50:31) [GCC 4.0.1 (Apple Inc. build 5493)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> b'\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf'.decode('utf8') '哈斯朝魯' K On Sunday, May 25, 2014 9:23:47 PM UTC-7, hito koto

Re: Django queryset csv encode

2014-05-25 Thread hito koto
Hi, I7m try that's this time not the error but output the ['\xe5\x93\x88\xe6\x96\xaf\xe6\x9c\x9d\xe9\xad\xaf'] 2014年5月26日月曜日 13時15分41秒 UTC+9 WongoBongo: > > Try > > name = [name.encode("utf8") for name in Staff.objects.filter(id = > 3).values_list('user_name', *flat=True*)] > > The other

Re: Django queryset csv encode

2014-05-25 Thread Kelvin Wong
Try name = [name.encode("utf8") for name in Staff.objects.filter(id = 3).values_list('user_name', *flat=True*)] The other returns one-tuples in a list https://docs.djangoproject.com/en/dev/ref/models/querysets/#values-list K On Sunday, May 25, 2014 7:55:51 PM UTC-7, hito koto wrote: > > Hi, >

Django queryset csv encode

2014-05-25 Thread hito koto
Hi, I want to encode in utf8 but don't know how can i to ? i have the errors is here: AttributeError: 'tuple' object has no attribute 'encode' My code is here : name = [name.encode("utf8") for name in Staff.objects.filter(id = 3).values_list('user_name')] -- You received this message becaus