perf: 优化 label choice

pull/12401/head
ibuler 2023-12-21 16:45:38 +08:00 committed by 老广
parent febf08629a
commit bc5494bbb0
1 changed files with 3 additions and 4 deletions

View File

@ -66,10 +66,9 @@ class LabeledChoiceField(ChoiceField):
def to_internal_value(self, data):
if isinstance(data, dict):
data = data.get("value")
if "(" in data and data.endswith(")"):
d = data.strip(")").split('(')[-1]
if d in self.choices:
data = d
if isinstance(data, str) and "(" in data and data.endswith(")"):
data = data.strip(")").split('(')[-1]
return super(LabeledChoiceField, self).to_internal_value(data)