          related = getattr(relation, 'related_model', relation.model)
          reverse_relations[accessor_name] = RelationInfo(
              model_field=None,
              related_model=related,
              to_many=get_remote_field(relation.field).multiple,
              to_field=_get_to_field(relation.field),
              has_through_model=False,
              reverse=True
          )
  
 
</s> remove             related_model=get_related_model(field),
 </s> add             related_model=field.remote_field.model, </s> remove                 (getattr(get_remote_field(relation.field), 'through', None) is not None) and
                not get_remote_field(relation.field).through._meta.auto_created
 </s> add                 (getattr(relation.field.remote_field, 'through', None) is not None) and
                not relation.field.remote_field.through._meta.auto_created </s> remove         set_many(self.instance, 'many_to_many', self.many_to_many_targets)
        self.instance.save()
 </s> add         self.instance.many_to_many.set(self.many_to_many_targets) </s> remove     for field in [field for field in opts.fields if field.serialize and get_remote_field(field)]:
 </s> add     for field in [field for field in opts.fields if field.serialize and field.remote_field]: </s> remove             related_model=get_related_model(field),
 </s> add             related_model=field.remote_field.model,
            to_many=relation.field.remote_field.multiple,
          related = getattr(relation, 'related_model', relation.model)
          reverse_relations[accessor_name] = RelationInfo(
              model_field=None,
              related_model=related,
            to_many=relation.field.remote_field.multiple,
              to_field=_get_to_field(relation.field),
              has_through_model=False,
              reverse=True
          )
  
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/model_meta.py