ojuso-map/apps/map/widgets.py

22 lines
535 B
Python
Raw Normal View History

2018-04-23 05:15:33 +00:00
from django.forms import widgets
class CommaSeparatedTextInput(widgets.HiddenInput):
def format_value(self, value):
try:
value = ','.join(value)
except TypeError:
value = ''
return super().format_value(value)
def value_from_datadict(self, data, files, name):
value = super().value_from_datadict(data, files, name)
if value == '':
return None
try:
return value.split(',')
except AttributeError:
return None