  
      def __init__(self, method, detail=None, code=None):
          if detail is None:
              detail = force_text(self.default_detail).format(method=method)
          super(MethodNotAllowed, self).__init__(detail, code)
  
  
  class NotAcceptable(APIException):
      status_code = status.HTTP_406_NOT_ACCEPTABLE
      default_detail = _('Could not satisfy the request Accept header.')
 
</s> remove         return super(APIRequestFactory, self).generic(
 </s> add         return super().generic( </s> remove         request = super(APIRequestFactory, self).request(**kwargs)
 </s> add         request = super().request(**kwargs) </s> remove         class MockQuerySet(object):
 </s> add         class MockQuerySet: </s> remove         super(DurationField, self).__init__(**kwargs)
 </s> add         super().__init__(**kwargs) </s> remove             content_type = "{0}; charset={1}".format(media_type, charset)
 </s> add             content_type = "{}; charset={}".format(media_type, charset)
        super().__init__(detail, code)
  
      def __init__(self, method, detail=None, code=None):
          if detail is None:
              detail = force_text(self.default_detail).format(method=method)
        super().__init__(detail, code)
  
  
  class NotAcceptable(APIException):
      status_code = status.HTTP_406_NOT_ACCEPTABLE
      default_detail = _('Could not satisfy the request Accept header.')
keep keep keep keep replace keep keep keep keep keep
 Dropped Python 2 compatibility. (#6615)

Thanks to Jon Dufresne (@jdufresne) for review.

Co-authored-by: Asif Saif Uddin <auvipy@gmail.com>
Co-authored-by: Rizwan Mansuri <Rizwan@webbyfox.com> 
rest_framework/exceptions.py