Hello guys
After playing with Django 0.91 I've found that it behaves not 100%
correct when MySQL 4.1 is used.
File django/core/db/backends/mysql.py contains code:
if self.connection.get_server_info() >= '4.1':
cursor.execute("SET NAMES utf8")
It means that unicode will be always forced when MySQL 4.1 is used but
this may be wrong ! For example I have a russian site which I want to
move to Django. I already have ready html templates and they are in
windows-1251 encoding and I am able to use them with my data when I run
SET NAMES cp1251 without any recoding BUT Django doesnt allow me to do
the same because unicode support is hardcoded.
I wrote a small path to fix this problem. Does anyone need it ? Where
should I post it ?
It's quite simple and just adds a new parameter to the settings file
which is used only when MySQL 4.1 is used (DATABASE_CHARSET) and by
default it is "utf8" to support backwards compatibility.
I think it should be put into upstream. Shouldnt it ?
diff
/usr/lib/python2.3/site-packages/Django-0.91-py2.3.egg/django/core/db/backends/mysql.py
/usr/lib/python2.3/site-packages/Django-0.91-py2.3.egg/jango/core/db/backends/mysql.py.orig
56c56
< from django.conf.settings import DATABASE_USER,
DATABASE_NAME, DATABASE_HOST, DATABASE_PORT, DATABASE_PASSWORD,
DATABASE_CHARSET, DEBUG
---
> from django.conf.settings import DATABASE_USER, DATABASE_NAME,
> DATABASE_HOST, DATABASE_PORT, DATABASE_PASSWORD, DEBUG
70c70
< cursor.execute("SET NAMES %s" % DATABASE_CHARSET)
---
> cursor.execute("SET NAMES utf8")
diff
/usr/lib/python2.3/site-packages/Django-0.91-py2.3.egg/django/conf/global_settings.py
/usr/lib/python2.3/site-packages/Django-0.91-py2.3.egg/django/conf/global_settings.py.orig
83d82
< DATABASE_CHARSET = 'utf8' # Used with MySQL 4.1.x and higher
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django developers" 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-developers
-~----------~----~----~----~------~----~------~--~---