  
  import copy
  import inspect
  import traceback
  from collections import OrderedDict
  
  from django.core.exceptions import ValidationError as DjangoValidationError
  from django.core.exceptions import ImproperlyConfigured
  from django.db import models
  from django.db.models import DurationField as ModelDurationField
 
</s> remove             key: value if isinstance(value, (list, dict)) else [value]
 </s> add             key: value if isinstance(value, (list, Mapping)) else [value] </s> remove         if not isinstance(data, dict):
 </s> add         if not isinstance(data, Mapping): </s> remove     if isinstance(detail, dict):
 </s> add     if isinstance(detail, Mapping):
from collections import Mapping, OrderedDict
  
  import copy
  import inspect
  import traceback
from collections import Mapping, OrderedDict
  
  from django.core.exceptions import ValidationError as DjangoValidationError
  from django.core.exceptions import ImproperlyConfigured
  from django.db import models
  from django.db.models import DurationField as ModelDurationField
keep keep keep keep replace keep keep keep keep keep
 Check for collection.Mapping instead of dict

issue #4901 
rest_framework/serializers.py