Skip to content

Commit 2be1a68

Browse files
committed
If the choices are Proxy str (i18n) patched_display_for_field gets an error
1 parent 8bafbdb commit 2be1a68

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ This code is inspired by django code. It is possible that for other versions of
261261
if isinstance(field, MultiSelectField) and getattr(field, "flatchoices", None):
262262
try:
263263
flatchoices = dict(field.flatchoices)
264-
return ', '.join([flatchoices.get(v, empty_value_display) for v in value]) or empty_value_display
264+
return ', '.join([str(flatchoices.get(v, empty_value_display)) for v in value]) or empty_value_display
265265
except TypeError:
266266
# Allow list-like choices.
267267
flatchoices = dict(make_hashable(field.flatchoices))

example/app/apps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def patched_display_for_field(value, field, empty_value_display, avoid_link=Fals
3535
if isinstance(field, MultiSelectField) and getattr(field, "flatchoices", None):
3636
try:
3737
flatchoices = dict(field.flatchoices)
38-
return ', '.join([flatchoices.get(v, empty_value_display) for v in value]) or empty_value_display
38+
return ', '.join([str(flatchoices.get(v, empty_value_display)) for v in value]) or empty_value_display
3939
except TypeError:
4040
# Allow list-like choices.
4141
flatchoices = dict(make_hashable(field.flatchoices))

0 commit comments

Comments
 (0)