          # (In Django 1.9+ this differs from previous style)
          if isinstance(model_field, models.DecimalField) and DecimalValidator:
              validator_kwarg = [
                  validator for validator in validator_kwarg
                  if not isinstance(validator, DecimalValidator)
              ]
  
      # Ensure that max_length is passed explicitly as a keyword arg,
      # rather than as a validator.
      max_length = getattr(model_field, 'max_length', None)
 
</s> remove         # (In Django 1.9+ this differs from previous style)
        if isinstance(model_field, models.DecimalField) and DecimalValidator:
 </s> add         if isinstance(model_field, models.DecimalField): </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 # Obtaining manager instances and names from model options differs after 1.10.
def get_names_and_managers(options):
    if django.VERSION >= (1, 10):
        # Django 1.10 onwards provides a `.managers` property on the Options.
        return [
            (manager.name, manager)
            for manager
            in options.managers
        ]
    # For Django 1.8 and 1.9, use the three-tuple information provided
    # by .concrete_managers and .abstract_managers
    return [
        (manager_info[1], manager_info[2])
        for manager_info
        in (options.concrete_managers + options.abstract_managers)
    ]


# field.rel is deprecated from 1.9 onwards
def get_remote_field(field, **kwargs):
    if 'default' in kwargs:
        if django.VERSION < (1, 9):
            return getattr(field, 'rel', kwargs['default'])
        return getattr(field, 'remote_field', kwargs['default'])

    if django.VERSION < (1, 9):
        return field.rel
    return field.remote_field


 </s> add  </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 </s> remove # JSONField is only supported from 1.9 onwards
try:
    from django.contrib.postgres.fields import JSONField
except ImportError:
    JSONField = None


 </s> add 
                if not isinstance(validator, validators.DecimalValidator)
          # (In Django 1.9+ this differs from previous style)
          if isinstance(model_field, models.DecimalField) and DecimalValidator:
              validator_kwarg = [
                  validator for validator in validator_kwarg
                if not isinstance(validator, validators.DecimalValidator)
              ]
  
      # Ensure that max_length is passed explicitly as a keyword arg,
      # rather than as a validator.
      max_length = getattr(model_field, 'max_length', None)
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/utils/field_mapping.py