def output(request):
response = HttpResponse(mimetype='text/csv')
response['Content-Disposition'] = 'attachment; filename=%s' %
'address.csv'
t = loader.get_template('csv.html')
# objs = Address.objects.get_list()
objs = Address.objects.all()
d = []
for o in objs:
d.append((o.name, o.gender, o.telphone, o.mobile, o.room))
c = Context({
'data': d,
})
response.write(t.render(c))
return response
---------------------------------------------------------
I define a funtion to write some chinese into a csv type file,
but i I get this file and open it in windows, it will appear messy
code.
I know this file is encoded in utf-8 default, but I find the
response.write module
have no encoding method, because django just has utf-8 encoding.
how to write it encoding "Gb2312" or "GBK" or some others chinese
encoding.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---