Skip to content

Commit

Permalink
Update widgets.py
Browse files Browse the repository at this point in the history
Fixes error when a single value is stored in m2m relation field
  • Loading branch information
citmusa authored and bmihelac committed Jan 11, 2016
1 parent b0cfd28 commit ccff5ed
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions import_export/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ def __init__(self, model, separator=None, field=None, *args, **kwargs):
def clean(self, value):
if not value:
return self.model.objects.none()
if isinstance(value, float):
ids = [int(value)]
else:
ids = value.split(self.separator)
ids = filter(None, value.split(self.separator))
return self.model.objects.filter(**{
'%s__in' % self.field: ids
Expand Down

0 comments on commit ccff5ed

Please sign in to comment.