Hi, all!

I'm just starting to learn Django 0.96, implemented a simple website
and finally stuck with one simple markdown problem. My site is utf-8
and information i stored in sqlite. When i added markdown filter to my
template i got the following error:

Request Method:    GET
Request URL:    http://localhost:8000/
Exception Type:     UnicodeDecodeError
Exception Value:    'ascii' codec can't decode byte 0xd0 in position
0: ordinal not in range(128)
Exception Location:    /usr/lib/python2.5/site-packages/markdown.py in
removeBOM, line 74

Seems like python-markdown wants to remove BOM's from *unicode* string
and Django gives it a bytestring. Strange thing is that pysqlite
extracts data as unicode strings and then they are encoded to
bytestrings with django.db.backends.sqlite3.base.utf8rowFactory. I
changed the call to markdown from:

markdown.markdown(value)

to:

markdown.markdown(value.decode('utf-8'))

...and the problem dissapeared.

My question is why Django prefers to work with bytestrings internally
and how can i fix this problem properly?

Also I don't want to use SVN version. I peeked at markup module at SVN
and it seems like it still passes bytestrings to markdown, except this
time using smart_str()

Can someone help?


--~--~---------~--~----~------------~-------~--~----~
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