SlugRelatedFied many=True can cause UnicodeEncodeError · Issue #2290 · encode/django-rest-framework (original) (raw)

I am using SlugRelatedField with many=True, in DRF 3.0.1, on a slug (which isn't really a slug... it's a name) which can contain unicode characters. ManyRelatedField doesn't seem to be able to handle that as it pushes the choices through str() can/should this be changed?

UnicodeEncodeError: 'ascii' codec can't encode character u'\u0161' in position 0: ordinal not in range(128)

rest_framework/relations.py", line 370, in choices

365         return dict([
366             (
367                 str(item_representation),
368                 str(item) + ' - ' + str(item_representation)
369             )
370             for item, item_representation in items_and_representations
371         ])