  except ImportError:
      postgres_fields = None
  
  
  # JSONField is only supported from 1.9 onwards
  try:
      from django.contrib.postgres.fields import JSONField
  except ImportError:
      JSONField = None
  
  
  # coreapi is optional (Note that uritemplate is a dependency of coreapi)
  try:
      import coreapi
      import uritemplate
  except (ImportError, SyntaxError):
 
</s> remove try:
    # DecimalValidator is unavailable in Django < 1.9
    from django.core.validators import DecimalValidator
except ImportError:
    DecimalValidator = None
 </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 from rest_framework.compat import DecimalValidator, JSONField
 </s> add from rest_framework.compat import postgres_fields </s> remove                 if not isinstance(validator, DecimalValidator)
 </s> add                 if not isinstance(validator, validators.DecimalValidator) </s> remove from rest_framework.compat import get_related_model, get_remote_field

 </s> add 
  except ImportError:
      postgres_fields = None
  
  







  # coreapi is optional (Note that uritemplate is a dependency of coreapi)
  try:
      import coreapi
      import uritemplate
  except (ImportError, SyntaxError):
keep keep keep keep replace replace replace replace replace replace 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/compat.py