old_contents: from rest_framework.parsers import JSONParser
  from rest_framework.exceptions import ParseError
  
  from api.base.renderers import JSONAPIRenderer
  from api.base.exceptions import JSONAPIException
  
  
  NO_ATTRIBUTES_ERROR = 'Request must include /data/attributes.'
  NO_DATA_ERROR = 'Request must include /data.'
  
  class JSONAPIParser(JSONParser):
      """
      Parses JSON-serialized data. Overrides media_type.
      """
      media_type = 'application/vnd.api+json'
      renderer_class = JSONAPIRenderer
  
      def parse(self, stream, media_type=None, parser_context=None):
          """
          Parses the incoming bytestream as JSON and returns the resulting data
          """
          result = super(JSONAPIParser, self).parse(stream, media_type=media_type, parser_context=parser_context)
          if not isinstance(result, dict):
              raise ParseError()
          data = result.get('data', {})
  
          if data:
              if 'attributes' not in data:
                  raise JSONAPIException(source={'pointer': '/data/attributes'}, detail=NO_ATTRIBUTES_ERROR)
              id = data.get('id')
              object_type = data.get('type')
              attributes = data.get('attributes')
  
              parsed = {'id': id, 'type': object_type}
              parsed.update(attributes)
  
              return parsed
  
          else:
              raise JSONAPIException(source={'pointer': '/data'}, detail=NO_DATA_ERROR)
  
  
  class JSONAPIParserForRegularJSON(JSONAPIParser):
      media_type = 'application/json'
  
new_contents: from urlparse import urlparse
  from rest_framework.parsers import JSONParser
  from rest_framework.exceptions import ParseError
  
  from api.base.renderers import JSONAPIRenderer
  from api.base.exceptions import JSONAPIException
  
  NO_ATTRIBUTES_ERROR = 'Request must include /data/attributes.'
  NO_RELATIONSHIPS_ERROR = 'Request must include /data/relationships.'
  NO_DATA_ERROR = 'Request must include /data.'
  NO_TYPE_ERROR = 'Request must include /type.'
  
  
  class JSONAPIParser(JSONParser):
      """
      Parses JSON-serialized data. Overrides media_type.
      """
      media_type = 'application/vnd.api+json'
      renderer_class = JSONAPIRenderer
  
      def flatten_relationships(self, relationships):
          """
          Flatten relationships if used for creating relationships between resource objects
          """
          if not isinstance(relationships, dict):
                  raise ParseError()
          related_resource = relationships.keys()[0]
          if not isinstance(relationships[related_resource], dict):
              raise ParseError()
          data = relationships[related_resource].get('data')
  
          if not data:
              raise JSONAPIException(source={'pointer': '/relationships/<related_resource_name>/data'}, detail=NO_DATA_ERROR)
  
          target_type = data.get('type')
          if not target_type:
              raise JSONAPIException(source={'pointer': '/relationships/<related_resource_name>/data/type'}, detail=NO_TYPE_ERROR )
  
          if related_resource != target_type:
              raise JSONAPIException(source={'pointer': '/relationships/<related_resource_name>'}, detail='Related resource name must be related resource type.')
  
          id = data.get('id')
          return {'id': id, target_type: target_type}
  
  
      def parse(self, stream, media_type=None, parser_context=None):
          """
          Parses the incoming bytestream as JSON and returns the resulting data
          """
          result = super(JSONAPIParser, self).parse(stream, media_type=media_type, parser_context=parser_context)
          if not isinstance(result, dict):
              raise ParseError()
          data = result.get('data', {})
  
          if data:
              relationships = data.get('relationships')
  
              path = stream.path
              related_resources = ['contributors', 'node_links']
              for resource in related_resources:
                  if stream.method == 'POST' and resource in path and not relationships:
                      raise JSONAPIException(source={'pointer': '/data/relationships'}, detail=NO_RELATIONSHIPS_ERROR)
              else:
                  if 'attributes' not in data:
                      raise JSONAPIException(source={'pointer': '/data/attributes'}, detail=NO_ATTRIBUTES_ERROR)
  
  
              id = data.get('id')
              object_type = data.get('type')
              attributes = data.get('attributes')
  
              if relationships:
                  relationships = self.flatten_relationships(relationships)
  
              parsed = {'id': id, 'type': object_type}
  
              if attributes:
                  parsed.update(attributes)
  
              if relationships:
                  parsed.update(relationships)
  
              return parsed
  
          else:
              raise JSONAPIException(source={'pointer': '/data'}, detail=NO_DATA_ERROR)
  
  
  class JSONAPIParserForRegularJSON(JSONAPIParser):
      media_type = 'application/json'
  
subject: Add logic to parser to require 'relationships' object for contributors and node-links, rename type to target_type, and then flatten data. Requires that relationship dictionary is correct format.