Skip to content

SlugRelatedFied many=True can cause UnicodeEncodeError #2290

Closed
@stevelacey

Description

@stevelacey

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         ])

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions