          # transaction not managed
          pass
  
  
  def template_render(template, context=None, request=None):
      """
      Passing Context or RequestContext to Template.render is deprecated in 1.9+,
      see https://github.com/django/django/pull/3883 and
      https://github.com/django/django/blob/1.9/django/template/backends/django.py#L82-L84
  
      :param template: Template instance
      :param context: dict
      :param request: Request instance
      :return: rendered template as SafeText instance
      """
      if isinstance(template, Template):
          if request:
              context = RequestContext(request, context)
          else:
              context = Context(context)
          return template.render(context)
      # backends template, e.g. django.template.backends.django.Template
      else:
          return template.render(context, request=request)
  
  
  def set_many(instance, field, value):
      if django.VERSION < (1, 10):
          setattr(instance, field, value)
      else:
          field = getattr(instance, field)
          field.set(value)
  
  
  def include(module, namespace=None, app_name=None):
      from django.conf.urls import include
      if django.VERSION < (1,9):
          return include(module, namespace, app_name)
      else:
          return include((module, app_name), namespace)
  
  
  def authenticate(request=None, **credentials):
      from django.contrib.auth import authenticate
      if django.VERSION < (1, 11):
          return authenticate(**credentials)
      else:
 
</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 # 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             return template_render(template, context, request=request)
 </s> add             return template.render(context, request=request) </s> remove         return template_render(template, context, request=request)
 </s> add         return template.render(context, request=request) </s> remove         return template_render(template, context)
 </s> add         return template.render(context)
          # transaction not managed
          pass
  
  






































  def authenticate(request=None, **credentials):
      from django.contrib.auth import authenticate
      if django.VERSION < (1, 11):
          return authenticate(**credentials)
      else:
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace 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