First of all i would like to know if it is exists a way to represent
filenames in different encodings with django.
Seems i've tried everything, but cannot get rid of UnicodeDecodeError/
UnicodeEncodeError messages.

There is my view:

from django.shortcuts import render_to_response
from django.utils.encoding import smart_unicode
import os

def tst(request):
    return render_to_response('index.html', {'ls': [smart_unicode(x)
for x in os.listdir('/home/ftp/grey')],})

template:

{%for i in ls%}{{i}}{%endfor%}

error:

Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py"
in get_response
  77. response = callback(request, *callback_args, **callback_kwargs)
File "/home/grey/src/df/fs/views.py" in tst
  6. return render_to_response('index.html', {'ls': [smart_unicode(x)
for x in os.listdir('/home/ftp/grey')],})
File "/usr/lib/python2.4/site-packages/django/utils/encoding.py" in
smart_unicode
  24. return force_unicode(s, encoding, strings_only, errors)
File "/usr/lib/python2.4/site-packages/django/utils/encoding.py" in
force_unicode
  41. s = unicode(s, encoding, errors)

  UnicodeDecodeError at /ftp/
  'utf8' codec can't decode bytes in position 0-1: invalid data


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to