• Sept. 25, 2016, 3:22 a.m.

    here is the problem:

    ==========

    OperationalError at /admincp/forums/new/
    (1366, "Incorrect string value: '\xE6\xB5\x8B\xE8\xAF\x95...' for column 'name' at row 1")
    Request Method: POST
    Request URL: http://192.168.199.237:8000/admincp/forums/new/
    Django Version: 1.6.4
    Exception Type: OperationalError
    Exception Value:
    (1366, "Incorrect string value: '\xE6\xB5\x8B\xE8\xAF\x95...' for column 'name' at row 1")
    Exception Location: /usr/lib64/python2.7/site-packages/MySQLdb/connections.py in defaulterrorhandler, line 36
    Python Executable: /usr/bin/python
    Python Version: 2.7.5
    Python Path:
    ['/home/lthpc/Infrastructure/Misago-0.5.7',
    '/usr/lib64/python27.zip',
    '/usr/lib64/python2.7',
    '/usr/lib64/python2.7/plat-linux2',
    '/usr/lib64/python2.7/lib-tk',
    '/usr/lib64/python2.7/lib-old',
    '/usr/lib64/python2.7/lib-dynload',
    '/usr/lib64/python2.7/site-packages',
    '/usr/lib64/python2.7/site-packages/gtk-2.0',
    '/usr/lib/python2.7/site-packages',
    '/usr/lib/python2.7/site-packages/Misago-0.6a1.dev1-py2.7.egg',
    '/usr/lib/python2.7/site-packages/Unidecode-0.4.19-py2.7.egg',
    '/usr/lib/python2.7/site-packages/requests-2.11.1-py2.7.egg',
    '/usr/lib/python2.7/site-packages/psycopg2-2.6.1-py2.7-linux-x86_64.egg',
    '/usr/lib/python2.7/site-packages/Pillow-3.2.0-py2.7-linux-x86_64.egg',
    '/usr/lib/python2.7/site-packages/path.py-8.2.1-py2.7.egg',
    '/usr/lib/python2.7/site-packages/html5lib-0.9999999-py2.7.egg',
    '/usr/lib/python2.7/site-packages/fake_factory-0.5.11-py2.7.egg',
    '/usr/lib/python2.7/site-packages/django_htmlmin-0.9.1-py2.7.egg',
    '/usr/lib/python2.7/site-packages/django_crispy_forms-1.6.0-py2.7.egg',
    '/usr/lib/python2.7/site-packages/bleach-1.4.3-py2.7.egg',
    '/usr/lib/python2.7/site-packages/beautifulsoup4-4.4.1-py2.7.egg',
    '/usr/lib/python2.7/site-packages/djangorestframework-3.3.3-py2.7.egg',
    '/usr/lib/python2.7/site-packages/ipaddress-1.0.17-py2.7.egg',
    '/usr/lib/python2.7/site-packages/python_dateutil-2.5.3-py2.7.egg',
    '/usr/lib/python2.7/site-packages/argparse-1.4.0-py2.7.egg',
    '/usr/lib/python2.7/site-packages/sqlparse-0.2.1-py2.7.egg']
    Server time: Sun, 25 Sep 2016 11:20:02 +0800

    ===========

    I would like to create a new forum with Chinese name, however errors show.

  • Project Lead Sept. 25, 2016, 6:39 p.m.

    Can you please provide complete stack trace?

  • Sept. 25, 2016, 11:43 p.m.

    sure, thanks!

    =========

    Environment:

    Request Method: POST
    Request URL: http://222.200.179.21:8000/admincp/forums/new/

    Django Version: 1.6.4
    Python Version: 2.7.5
    Installed Applications:
    ('south',
    'django.contrib.staticfiles',
    'django.contrib.humanize',
    'django_jinja',
    'django_jinja.contrib._humanize',
    'floppyforms',
    'mptt',
    'haystack',
    'debug_toolbar',
    'misago')
    Installed Middleware:
    ('misago.middleware.thread.ThreadMiddleware',
    'misago.middleware.stopwatch.StopwatchMiddleware',
    'misago.middleware.heartbeat.HeartbeatMiddleware',
    'debug_toolbar.middleware.DebugToolbarMiddleware',
    'misago.middleware.cookiejar.CookieJarMiddleware',
    'misago.middleware.theme.ThemeMiddleware',
    'misago.middleware.firewalls.FirewallMiddleware',
    'misago.middleware.crawlers.DetectCrawlerMiddleware',
    'misago.middleware.session.SessionMiddleware',
    'misago.middleware.bruteforce.JamMiddleware',
    'misago.middleware.csrf.CSRFMiddleware',
    'misago.middleware.banning.BanningMiddleware',
    'misago.middleware.messages.MessagesMiddleware',
    'misago.middleware.user.UserMiddleware',
    'misago.middleware.mailsqueue.MailsQueueMiddleware',
    'misago.middleware.acl.ACLMiddleware',
    'misago.middleware.privatethreads.PrivateThreadsMiddleware',
    'django.middleware.common.CommonMiddleware')

    Traceback:
    File "/usr/lib64/python2.7/site-packages/django/core/handlers/base.py" in get_response
    114. response = wrapped_callback(request, callback_args, callback_kwargs)
    File "/home/lthpc/Infrastructure/Misago/misago/apps/admin/widgets.py" in new
    36. return obj(request,
    kwargs)
    File "/home/lthpc/Infrastructure/Misago/misago/apps/admin/widgets.py" in call
    438. model, message = self.submit_form(form, model)
    File "/home/lthpc/Infrastructure/Misago/misago/apps/admin/forums/views.py" in submit_form
    188. new_forum.insert_at(form.cleaned_data['parent'], position='last-child', save=True)
    File "/usr/lib/python2.7/site-packages/mptt/models.py" in insert_at
    557. self._tree_manager.insert_node(self, target, position, save, allow_existing_pk=allow_existing_pk)
    File "/usr/lib/python2.7/site-packages/mptt/managers.py" in insert_node
    250. node.save()
    File "/home/lthpc/Infrastructure/Misago/misago/models/forummodel.py" in save
    205. super(Forum, self).save(
    args, kwargs)
    File "/usr/lib/python2.7/site-packages/mptt/models.py" in save
    717. super(MPTTModel, self).save(*args,
    kwargs)
    File "/usr/lib64/python2.7/site-packages/django/db/models/base.py" in save
    545. force_update=force_update, update_fields=update_fields)
    File "/usr/lib64/python2.7/site-packages/django/db/models/base.py" in save_base
    573. updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
    File "/usr/lib64/python2.7/site-packages/django/db/models/base.py" in _save_table
    654. result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
    File "/usr/lib64/python2.7/site-packages/django/db/models/base.py" in _do_insert
    687. using=using, raw=raw)
    File "/usr/lib64/python2.7/site-packages/django/db/models/manager.py" in _insert
    232. return insert_query(self.model, objs, fields, **kwargs)
    File "/usr/lib64/python2.7/site-packages/django/db/models/query.py" in insert_query
    1511. return query.get_compiler(using=using).execute_sql(return_id)
    File "/usr/lib64/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
    903. cursor.execute(sql, params)
    File "/usr/lib64/python2.7/site-packages/django/db/backends/util.py" in execute
    69. return super(CursorDebugWrapper, self).execute(sql, params)
    File "/usr/lib64/python2.7/site-packages/django/db/backends/util.py" in execute
    53. return self.cursor.execute(sql, params)
    File "/usr/lib64/python2.7/site-packages/django/db/utils.py" in exit
    99. six.reraise(dj_exc_type, dj_exc_value, traceback)
    File "/usr/lib64/python2.7/site-packages/django/db/backends/util.py" in execute
    53. return self.cursor.execute(sql, params)
    File "/usr/lib64/python2.7/site-packages/django/db/backends/mysql/base.py" in execute
    124. return self.cursor.execute(query, args)
    File "/usr/lib64/python2.7/site-packages/MySQLdb/cursors.py" in execute
    174. self.errorhandler(self, exc, value)
    File "/usr/lib64/python2.7/site-packages/MySQLdb/connections.py" in defaulterrorhandler
    36. raise errorclass, errorvalue

    Exception Type: OperationalError at /admincp/forums/new/
    Exception Value: (1366, "Incorrect string value: '\xE6\xB5\x8B\xE8\xAF\x95...' for column 'name' at row 1")

  • Sept. 27, 2016, 5:02 p.m.

    are there any solution plz .... ?

  • Project Lead Sept. 27, 2016, 8:16 p.m.

    According to Google the error is caused by Django encoding MySQL database as utf8 which uses 3 bytes to store characters, and your characters are four byte long, and should be encoded via utf8mb4. You could try if this is true and change your db's connection/tables/columns encoding via, say, PHPMyAdmin, and see if this fixed problem.

    Just make sure you've backed your database up first.

  • Oct. 8, 2016, 5:35 p.m.

    Hi, I have tried this way but fail.

    1, I set MYSQL charset like below
    屏幕快照 2016-10-09 上午1.33.28.png

    2, I set the django DB connect
    屏幕快照 2016-10-09 上午1.33.00.png

    But error still happens. What should I do? thanks!

    屏幕快照 2016-10-09 上午1.33.28.png

    PNG, 76.5 KB, uploaded by terryyang93 on Oct. 8, 2016.

    屏幕快照 2016-10-09 上午1.33.00.png

    PNG, 31.7 KB, uploaded by terryyang93 on Oct. 8, 2016.

  • Project Lead Oct. 8, 2016, 5:55 p.m.

    Did you change encoding for database tables fields too?

  • Oct. 9, 2016, 2:29 a.m.

    yes, I solved it! thank you so much!

  • Nov. 23, 2016, 3:46 a.m.

    Thanks, solves my problem!

  • Feb. 21, 2017, 6:01 a.m.

    excellent ! good to see the program can works in Chineselanguage.