Fix Django REST framework AttributeError: 'Request' object has no attribute 'accepted_renderer'

Fix Django REST framework AttributeError: 'Request' object has no attribute 'accepted_renderer'

drf

Below are ways to fix AttributeError: 'Request' object has no attribute 'accepted_renderer' error.

 

1. Install pyyaml

pip install pyyaml

 

OR

 

2. Revert Django REST Framework (DRF)

pip install djangorestframework==3.8.0

 

OR

 

3. Ignore decode on your ViewSet

class MyCoolViewset(viewsets.ModelViewSet):
  def _clean_data(self, data):
        if isinstance(data, bytes):
            data = data.decode(errors='ignore')
        return super(MyCoolViewset, self)._clean_data(data)

 

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.