  
  import inspect
  import pickle
  import re
  
  import pytest
  from django.db import models
  
  from rest_framework import fields, relations, serializers
 
</s> remove from collections import OrderedDict
 </s> add from collections import Mapping, OrderedDict </s> remove         if not isinstance(data, dict):
 </s> add         if not isinstance(data, Mapping): </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 isinstance(detail, dict):
 </s> add     if isinstance(detail, Mapping):
import unittest
from collections import Mapping
  
  import inspect
  import pickle
  import re
import unittest
from collections import Mapping
  
  import pytest
  from django.db import models
  
  from rest_framework import fields, relations, serializers
keep keep keep add keep keep keep keep keep
 Check for collection.Mapping instead of dict

issue #4901 
tests/test_serializer.py