Optimize multiselectfield to_python method. (#106)
* Optimize multiselectfield to_python method. When using with django import export plugin, optimize these 2 things: 1. User usally input a " " after ",", optimize the parse method, trim it. 2. User also can input "," instead of ",", for a better user experience. * Update fields.py
This commit is contained in:
parent
9e44443275
commit
794bd41546
1 changed files with 2 additions and 1 deletions
|
@ -152,7 +152,8 @@ class MultiSelectField(models.CharField):
|
||||||
if isinstance(value, list):
|
if isinstance(value, list):
|
||||||
return value
|
return value
|
||||||
elif isinstance(value, string_type):
|
elif isinstance(value, string_type):
|
||||||
return MSFList(choices, value.split(','))
|
value_list = map(lambda x: x.strip(), value.replace(u',', ',').split(','))
|
||||||
|
return MSFList(choices, value_list)
|
||||||
elif isinstance(value, (set, dict)):
|
elif isinstance(value, (set, dict)):
|
||||||
return MSFList(choices, list(value))
|
return MSFList(choices, list(value))
|
||||||
return MSFList(choices, [])
|
return MSFList(choices, [])
|
||||||
|
|
Loading…
Reference in a new issue