      rel = get_remote_field(pk)
  
      while rel and rel.parent_link:
          # If model is a child via multi-table inheritance, use parent's pk.
          pk = get_related_model(pk)._meta.pk
          rel = get_remote_field(pk)
  
      return pk
  
  
  def _get_fields(opts):
 
</s> remove     rel = get_remote_field(pk)
 </s> add     rel = pk.remote_field </s> remove         rel = get_remote_field(self.model_field, default=None)
 </s> add         rel = self.model_field.remote_field </s> remove         set_many(self.user, 'groups', self.groups)
        self.user.save()
 </s> add         self.user.groups.set(self.groups) </s> remove     def test_get_remote_field_with_old_django_version(self):
        class MockField(object):
            rel = 'example_rel'
        compat.django.VERSION = (1, 8)
        assert compat.get_remote_field(MockField(), default='default_value') == 'example_rel'
        assert compat.get_remote_field(object(), default='default_value') == 'default_value'

    def test_get_remote_field_with_new_django_version(self):
        class MockField(object):
            remote_field = 'example_remote_field'
        compat.django.VERSION = (1, 10)
        assert compat.get_remote_field(MockField(), default='default_value') == 'example_remote_field'
        assert compat.get_remote_field(object(), default='default_value') == 'default_value'

 </s> add  </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)):
        pk = pk.remote_field.model._meta.pk
        rel = pk.remote_field
      rel = get_remote_field(pk)
  
      while rel and rel.parent_link:
          # If model is a child via multi-table inheritance, use parent's pk.
        pk = pk.remote_field.model._meta.pk
        rel = pk.remote_field
        pk = pk.remote_field.model._meta.pk
        rel = pk.remote_field
  
      return pk
  
  
  def _get_fields(opts):
keep keep keep keep 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/utils/model_meta.py