              self.validators.append(
                  MaxLengthValidator(self.max_length, message=message))
  
      def to_internal_value(self, data):
          rel = get_remote_field(self.model_field, default=None)
          if rel is not None:
              return rel.model._meta.get_field(rel.field_name).to_python(data)
          return self.model_field.to_python(data)
  
      def get_attribute(self, obj):
 
</s> remove         pk = get_related_model(pk)._meta.pk
        rel = get_remote_field(pk)
 </s> add         pk = pk.remote_field.model._meta.pk
        rel = pk.remote_field </s> remove     rel = get_remote_field(pk)
 </s> add     rel = pk.remote_field </s> remove     if isinstance(model_field, models.TextField) or (JSONField and isinstance(model_field, JSONField)):
 </s> add     if isinstance(model_field, models.TextField) or (postgres_fields and isinstance(model_field, postgres_fields.JSONField)): </s> remove         value = value_from_object(self.model_field, obj)
 </s> add         value = self.model_field.value_from_object(obj) </s> remove def is_authenticated(user):
    if django.VERSION < (1, 10):
        return user.is_authenticated()
    return user.is_authenticated


def is_anonymous(user):
    if django.VERSION < (1, 10):
        return user.is_anonymous()
    return user.is_anonymous


def get_related_model(field):
    if django.VERSION < (1, 9):
        return _resolve_model(field.rel.to)
    return field.remote_field.model


def value_from_object(field, obj):
    if django.VERSION < (1, 9):
        return field._get_val_from_obj(obj)
    return field.value_from_object(obj)


# contrib.postgres only supported from 1.8 onwards.
 </s> add # django.contrib.postgres requires psycopg2
        rel = self.model_field.remote_field
              self.validators.append(
                  MaxLengthValidator(self.max_length, message=message))
  
      def to_internal_value(self, data):
        rel = self.model_field.remote_field
          if rel is not None:
              return rel.model._meta.get_field(rel.field_name).to_python(data)
          return self.model_field.to_python(data)
  
      def get_attribute(self, obj):
keep keep keep keep replace keep keep keep keep keep
 Remove Django 1.8 & 1.9 compatibility code (#5481)

* Identify code that needs to be pulled out of/removed from compat.py

* Extract modern code from get_names_and_managers in compat.py and remove compat code

* Extract modern code from is_authenticated() in compat.py and remove.

* Extract modern code from is_anonymous() in compat.py and remove

* Extract modern code from get_related_model() from compat.py and remove

* Extract modern code from value_from_object() in compat.py and remove

* Update postgres compat

JSONField now always available.

* Remove DecimalValidator compat

* Remove get_remote_field compat

* Remove template_render compat

Plus isort.

* Remove set_many compat

* Remove include compat 
rest_framework/fields.py