diff --git a/rest_framework/compat.py b/rest_framework/compat.py index 2d77df490..1095c04df 100644 --- a/rest_framework/compat.py +++ b/rest_framework/compat.py @@ -115,12 +115,6 @@ def _resolve_model(obj): raise ValueError("{0} is not a Django model".format(obj)) -# TODO: Remove -def value_from_object(field, obj): - if django.VERSION < (1, 9): - return field._get_val_from_obj(obj) - return field.value_from_object(obj) - # TODO: Remove # contrib.postgres only supported from 1.8 onwards. diff --git a/rest_framework/fields.py b/rest_framework/fields.py index 7a79ae93c..8fae159ab 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -33,7 +33,7 @@ from rest_framework import ISO_8601 from rest_framework.compat import ( InvalidTimeError, MaxLengthValidator, MaxValueValidator, MinLengthValidator, MinValueValidator, get_remote_field, unicode_repr, - unicode_to_repr, value_from_object + unicode_to_repr ) from rest_framework.exceptions import ErrorDetail, ValidationError from rest_framework.settings import api_settings @@ -1840,7 +1840,7 @@ class ModelField(Field): return obj def to_representation(self, obj): - value = value_from_object(self.model_field, obj) + value = self.model_field.value_from_object(obj) if is_protected_type(value): return value return self.model_field.value_to_string(obj)