Last active
January 18, 2017 18:32
-
-
Save walkness/75ac0b03438328f29ba84d36215feabf to your computer and use it in GitHub Desktop.
Simple mixin for DRF generic viewsets to prevent RawPostDataException error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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