Skip to content

Instantly share code, notes, and snippets.

@walkness
Last active January 18, 2017 18:32
Show Gist options
  • Save walkness/75ac0b03438328f29ba84d36215feabf to your computer and use it in GitHub Desktop.
Save walkness/75ac0b03438328f29ba84d36215feabf to your computer and use it in GitHub Desktop.
Simple mixin for DRF generic viewsets to prevent RawPostDataException error
from rest_framework.request import Request
class RequestMaybeInitializedMixin(object):
def initialize_request(self, request, *args, **kwargs):
drf_request = super(
RequestMaybeInitializedMixin, self).initialize_request(
request, *args, **kwargs)
if isinstance(request, Request):
return request
return drf_request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment