Skip to content

Commit

Permalink
Avoid calling Field.clean() unnecessarily twice
Browse files Browse the repository at this point in the history
  • Loading branch information
jdufresne committed Nov 24, 2017
1 parent 688034a commit 52a8c51
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions import_export/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,9 @@ def save(self, obj, data):
attrs = self.attribute.split('__')
for attr in attrs[:-1]:
obj = getattr(obj, attr, None)
if self.clean(data) != None or self.saves_null_values:
setattr(obj, attrs[-1], self.clean(data))
cleaned = self.clean(data)
if cleaned is not None or self.saves_null_values:
setattr(obj, attrs[-1], cleaned)

def export(self, obj):
"""
Expand Down

0 comments on commit 52a8c51

Please sign in to comment.