from rest_framework.parsers import BaseParser class GZHParser(BaseParser): media_type = "text/xml" def parse(self, stream, media_type=None, parser_context=None): cont = stream.read().decode('utf-8') return cont class JsonParser(BaseParser): media_type = "application/json" def parse(self, stream, media_type=None, parser_context=None): cont = stream.read().decode('utf-8') return cont