perf: 修改 labels 绑定引起的问题

This commit is contained in:
ibuler
2023-12-19 18:42:44 +08:00
committed by Bryan
parent 45425b11d2
commit 0b7552a6ee
8 changed files with 28 additions and 10 deletions

View File

@@ -105,7 +105,8 @@ class BaseFileRenderer(BaseRenderer):
elif isinstance(value, bool):
value = 'Yes' if value else 'No'
elif isinstance(field, LabeledChoiceField):
value = value.get('value', '')
value = value or {}
value = '{}({})'.format(value.get('label'), value.get('value'))
elif isinstance(field, ObjectRelatedField):
if field.many:
value = [self.to_id_name(v) for v in value]