I have an application that include Unicode strings (Greek and Hebrew),
running on a dev machine and an (inside the firewall) release machine
configured (to the best of my ability) with the same Python, Django,
MySql and connector.
When editing an object containing one of these strings on the release
machine, in the admin interface, when i save i get:
OperationalError at /admin/realia/lemmarelation/1597/
(1366, "Incorrect string value: '\\xE1\\xBC\\x80\\xCE\\xAE\\xCF...'
for column 'message' at row 1")
Request Method: POST
Request URL:
http://debuild/admin/realia/lemmarelation/1597/
Exception Type: OperationalError
Exception Value:
(1366, "Incorrect string value: '\\xE1\\xBC\\x80\\xCE\\xAE\\xCF...'
for column 'message' at row 1")
Exception Location: C:\Python24\Lib\site-packages\MySQLdb
\connections.py in defaulterrorhandler, line 35
Python Executable: C:\Program Files\Apache Software Foundation
\Apache2.2\bin\httpd.exe
Python Version: 2.4.3
Python Path: ['c:/design.ed/django/logos/', 'C:\\Python24\\lib\\site-
packages\\setuptools-0.6c6-py2.4.egg', 'C:\\Python24\\Lib\\site-
packages\\django', 'C:\\design.ed\\django', 'C:\\Program Files\\Apache
Software Foundation\\Apache2.2', 'C:\\WINDOWS\\system32\
\python24.zip', 'c:\\python24\\lib\\site-packages', 'C:\\Python24\
\Lib', 'C:\\Python24\\DLLs', 'C:\\Python24\\Lib\\lib-tk', 'C:\\Program
Files\\Apache Software Foundation\\Apache2.2\\bin', 'C:\\Python24', 'c:
\\design.ed\\python\\libronix', 'C:\\Python24\\lib\\site-packages\
\win32', 'C:\\Python24\\lib\\site-packages\\win32\\lib', 'C:\\Python24\
\lib\\site-packages\\Pythonwin']
Server time: Fri, 20 Feb 2009 16:51:59 -0800
'message' isn't in my model, so it's breaking somewhere in the Django
part, but i'm not sure why, or how to fix it. And i can't find
anything different about my two environments that explains why it
breaks on one machine, but works fine on the other. What seems like
the likely culprit is a UTF-8 string, whose collating method is
utf8_general_ci. It's not a single data value: attempting to edit any
object in this table seems to raise this error.
Here's the traceback:
Environment:
Request Method: POST
Request URL:
http://debuild/admin/realia/lemmarelation/1597/
Django Version: 1.0.2 final
Python Version: 2.4.3
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'logos.lcv',
'logos.places',
'logos.names',
'logos.agents',
'logos.realia']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware')
Traceback:
File "C:\Python24\Lib\site-packages\django\core\handlers\base.py" in
get_response
86. response = callback(request, *callback_args,
**callback_kwargs)
File "C:\Python24\Lib\site-packages\django\contrib\admin\sites.py" in
root
157. return self.model_page(request, *url.split('/',
2))
File "C:\Python24\Lib\site-packages\django\views\decorators\cache.py"
in _wrapped_view_func
44. response = view_func(request, *args, **kwargs)
File "C:\Python24\Lib\site-packages\django\contrib\admin\sites.py" in
model_page
176. return admin_obj(request, rest_of_url)
File "C:\Python24\Lib\site-packages\django\contrib\admin\options.py"
in __call__
197. return self.change_view(request, unquote(url))
File "C:\Python24\Lib\site-packages\django\db\transaction.py" in
_commit_on_success
238. res = func(*args, **kw)
File "C:\Python24\Lib\site-packages\django\contrib\admin\options.py"
in change_view
587. return self.response_change(request,
new_object)
File "C:\Python24\Lib\site-packages\django\contrib\admin\options.py"
in response_change
454. self.message_user(request, msg + ' ' + _("You may
edit it again below."))
File "C:\Python24\Lib\site-packages\django\contrib\admin\options.py"
in message_user
363. request.user.message_set.create(message=message)
File "C:\Python24\Lib\site-packages\django\db\models\fields
\related.py" in create
310. return super(RelatedManager, self).create
(**kwargs)
File "C:\Python24\Lib\site-packages\django\db\models\manager.py" in
create
99. return self.get_query_set().create(**kwargs)
File "C:\Python24\Lib\site-packages\django\db\models\query.py" in
create
319. obj.save(force_insert=True)
File "C:\Python24\Lib\site-packages\django\db\models\base.py" in save
311. self.save_base(force_insert=force_insert,
force_update=force_update)
File "C:\Python24\Lib\site-packages\django\db\models\base.py" in
save_base
383. result = manager._insert(values,
return_id=update_pk)
File "C:\Python24\Lib\site-packages\django\db\models\manager.py" in
_insert
138. return insert_query(self.model, values, **kwargs)
File "C:\Python24\Lib\site-packages\django\db\models\query.py" in
insert_query
894. return query.execute_sql(return_id)
File "C:\Python24\Lib\site-packages\django\db\models\sql
\subqueries.py" in execute_sql
309. cursor = super(InsertQuery, self).execute_sql(None)
File "C:\Python24\Lib\site-packages\django\db\models\sql\query.py" in
execute_sql
1734. cursor.execute(sql, params)
File "C:\Python24\Lib\site-packages\django\db\backends\util.py" in
execute
19. return self.cursor.execute(sql, params)
File "C:\Python24\Lib\site-packages\django\db\backends\mysql\base.py"
in execute
83. return self.cursor.execute(query, args)
File "C:\Python24\Lib\site-packages\MySQLdb\cursors.py" in execute
166. self.errorhandler(self, exc, value)
File "C:\Python24\Lib\site-packages\MySQLdb\connections.py" in
defaulterrorhandler
35. raise errorclass, errorvalue
Exception Type: OperationalError at /admin/realia/lemmarelation/1597/
Exception Value: (1366, "Incorrect string value: '\\xE1\\xBC\\x80\\xCE\
\xAE\\xCF...' for column 'message' at row 1")