  
  import copy
  import inspect
  import traceback
  from collections import Mapping, OrderedDict
  
  from django.core.exceptions import ImproperlyConfigured
  from django.core.exceptions import ValidationError as DjangoValidationError
  from django.db import models
  from django.db.models import DurationField as ModelDurationField
 
</s> remove from rest_framework.compat import postgres_fields, unicode_to_repr
 </s> add from rest_framework.compat import Mapping, postgres_fields, unicode_to_repr
from collections import OrderedDict
  
  import copy
  import inspect
  import traceback
from collections import OrderedDict
  
  from django.core.exceptions import ImproperlyConfigured
  from django.core.exceptions import ValidationError as DjangoValidationError
  from django.db import models
  from django.db.models import DurationField as ModelDurationField
keep keep keep keep replace keep keep keep keep keep
 Fix Python 3.8 compatibility (#6154) 
rest_framework/serializers.py