Further work on multi-file-upload
This commit is contained in:
21
apps/map/widgets.py
Normal file
21
apps/map/widgets.py
Normal file
@ -0,0 +1,21 @@
|
||||
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
|
Reference in New Issue
Block a user