description incident charset error
lprat opened this issue · 1 comments
FIR get error when i create new incident by API:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 149, in get_response
response = self.process_exception_by_middleware(e, request)
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 147, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
return view_func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/rest_framework/viewsets.py", line 87, in view
return self.dispatch(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/rest_framework/views.py", line 474, in dispatch
response = self.handle_exception(exc)
File "/usr/local/lib/python2.7/dist-packages/rest_framework/views.py", line 434, in handle_exception
self.raise_uncaught_exception(exc)
File "/usr/local/lib/python2.7/dist-packages/rest_framework/views.py", line 471, in dispatch
response = handler(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/rest_framework/mixins.py", line 78, in partial_update
return self.update(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/rest_framework/mixins.py", line 70, in update
self.perform_update(serializer)
File "./fir_api/views.py", line 51, in perform_update
instance = serializer.save()
File "/usr/local/lib/python2.7/dist-packages/rest_framework/serializers.py", line 187, in save
self.instance = self.update(self.instance, validated_data)
File "/usr/local/lib/python2.7/dist-packages/rest_framework/serializers.py", line 908, in update
instance.save()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 708, in save
force_update=force_update, update_fields=update_fields)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 736, in save_base
updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 801, in _save_table
forced_update)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 851, in _do_update
return filtered._update(values) > 0
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 645, in _update
return query.get_compiler(self.db).execute_sql(CURSOR)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 1149, in execute_sql
cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 848, in execute_sql
cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 95, in exit
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/mysql/base.py", line 112, in execute
return self.cursor.execute(query, args)
File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 174, in execute
self.errorhandler(self, exc, value)
File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
OperationalError: (1366, "Incorrect string value: '\xC2\x83\xC3\x82\xC2\xA9...' for column 'description' at row 1")
I try to fix:
- Add in fir/config/base.py : DEFAULT_CHARSET = 'utf-8'
- In mysql: ALTER TABLE incidents_incident CHANGE COLUMN
description
description
LONGTEXT CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' NOT NULL;
Regards
Fixed a while ago (when using docker, the charset used for FIR mysql tables is now utf8mb4
)