mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-23 10:03:57 +03:00
This accounts for none(null) values of rel.to when converting model fields from native
This commit is contained in:
parent
027c9079f6
commit
e74772b8a6
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user