Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion multi_email_field/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ def to_python(self, value):
# Return None if no input was given.
if not value:
return []
return [v.strip() for v in value.splitlines() if v != ""]
if isinstance(value, list):
return [v.strip() for v in value if v != ""]
else:
return [v.strip() for v in value.splitlines() if v != ""]

def validate(self, value):
""" Check if value consists only of valid emails. """
Expand Down
4 changes: 4 additions & 0 deletions multi_email_field/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ def test__to_python(self):
val = '[email protected]\[email protected]\r\[email protected]'
self.assertEquals(['[email protected]', '[email protected]', '[email protected]'],
f.to_python(val))
# Multi elements list values
val = ['[email protected]', '[email protected]', '[email protected]']
self.assertEquals(['[email protected]', '[email protected]', '[email protected]'],
f.to_python(val))

def test__validate(self):
f = MultiEmailFormField(required=True)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
description="Provides a model field and a form field to manage list of e-mails",
long_description=open(os.path.join(here, 'README.rst')).read() + '\n\n' +
open(os.path.join(here, 'CHANGES')).read(),
license='LGPL, see LICENSE file.',
license='LGPL',
install_requires=['Django'],
packages=find_packages(),
include_package_data=True,
Expand Down