          return base.filter(pk__in=set(queryset.values_list('pk', flat=True)))
      return queryset.distinct()
  
  
  def _resolve_model(obj):
      """
      Resolve supplied `obj` to a Django model class.
  
      `obj` must be a Django model class itself, or a string
      representation of one.  Useful in situations like GH #1225 where
      Django may not have resolved a string-based reference to a model in
      another model's foreign key definition.
  
      String representations should have the format:
          'appname.ModelName'
      """
      if isinstance(obj, six.string_types) and len(obj.split('.')) == 2:
          app_name, model_name = obj.split('.')
          resolved_model = apps.get_model(app_name, model_name)
          if resolved_model is None:
              msg = "Django did not return a model for {0}.{1}"
              raise ImproperlyConfigured(msg.format(app_name, model_name))
          return resolved_model
      elif inspect.isclass(obj) and issubclass(obj, models.Model):
          return obj
      raise ValueError("{0} is not a Django model".format(obj))
  
  
  # django.contrib.postgres requires psycopg2
  try:
      from django.contrib.postgres import fields as postgres_fields
  except ImportError:
      postgres_fields = None
 
</s> remove class ResolveModelTests(TestCase):
    """
    `_resolve_model` should return a Django model class given the
    provided argument is a Django model class itself, or a properly
    formatted string representation of one.
    """
    def test_resolve_django_model(self):
        resolved_model = _resolve_model(BasicModel)
        assert resolved_model == BasicModel

    def test_resolve_string_representation(self):
        resolved_model = _resolve_model('tests.BasicModel')
        assert resolved_model == BasicModel

    def test_resolve_unicode_representation(self):
        resolved_model = _resolve_model(six.text_type('tests.BasicModel'))
        assert resolved_model == BasicModel

    def test_resolve_non_django_model(self):
        with self.assertRaises(ValueError):
            _resolve_model(TestCase)

    def test_resolve_improper_string_representation(self):
        with self.assertRaises(ValueError):
            _resolve_model('BasicModel')


class ResolveModelWithPatchedDjangoTests(TestCase):
    """
    Test coverage for when Django's `get_model` returns `None`.

    Under certain circumstances Django may return `None` with `get_model`:
    http://git.io/get-model-source

    It usually happens with circular imports so it is important that DRF
    excepts early, otherwise fault happens downstream and is much more
    difficult to debug.

    """

    def setUp(self):
        """Monkeypatch get_model."""
        self.get_model = rest_framework.compat.apps.get_model

        def get_model(app_label, model_name):
            return None

        rest_framework.compat.apps.get_model = get_model

    def tearDown(self):
        """Revert monkeypatching."""
        rest_framework.compat.apps.get_model = self.get_model

    def test_blows_up_if_model_does_not_resolve(self):
        with self.assertRaises(ImproperlyConfigured):
            _resolve_model('tests.BasicModel')


 </s> add  </s> remove from django.core.exceptions import ImproperlyConfigured
from django.db import models
 </s> add  </s> remove import inspect

 </s> add  </s> remove from django.core.exceptions import ImproperlyConfigured
 </s> add  </s> remove import rest_framework.utils.model_meta
from rest_framework.compat import _resolve_model
 </s> add 
          return base.filter(pk__in=set(queryset.values_list('pk', flat=True)))
      return queryset.distinct()
  
  
























  # django.contrib.postgres requires psycopg2
  try:
      from django.contrib.postgres import fields as postgres_fields
  except ImportError:
      postgres_fields = None
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 keep keep keep keep keep
 Remove unused compat._resolve_model() (#5733)

Last use removed in c674687782ef96a3bb8466b412e99debd3d04f00. 
rest_framework/compat.py