dominno / django-moderation

django-moderation is reusable application for Django framework, that allows to moderate any model objects.
BSD 3-Clause "New" or "Revised" License
269 stars 90 forks source link

UnicodeEncodeError when editing instances with unicode fields #122

Closed ebrelsford closed 9 years ago

ebrelsford commented 10 years ago

I'm seeing a UnicodeEncodeError when editing an instance with unicode in its text fields. It happens in diff.

I've worked around this in a local version of django-moderation by encoding value1 and value2 to utf-8 before sending them to TextChange, but I'm not sure that's the best place or solution. Has anyone else run into this, or am I just doing something wrong?

potar commented 10 years ago

@ebrelsford I have this issue too.

rmartins90 commented 10 years ago

https://github.com/dominno/django-moderation/issues/124

solved it with following changes on diff.py:

value1, value2 = change
if value1 and (type(value1) is str or type(value1) is unicode):
  value1 = value1.encode('utf-8')
if value2 and (type(value2) is str or type(value2) is unicode):
  value2 = value2.encode('utf-8')