Commit 756297ad by Otto Yiu

fix 'from_native' method when rel is None

'NoneType' object has no attribute 'to'
parent 96dc9ce1
......@@ -211,9 +211,9 @@ class ModelField(WritableField):
def from_native(self, value):
try:
rel = self.model_field.rel
return rel.to._meta.get_field(rel.field_name).to_python(value)
except:
return self.model_field.to_python(value)
return rel.to._meta.get_field(rel.field_name).to_python(value)
def field_to_native(self, obj, field_name):
value = self.model_field._get_val_from_obj(obj)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment