Base level method for removing data from the API

def _delete_json(self, instance, space=None, rel_path=None, extra_params=None, id_field=None, append_to_path=None):
        """
        Base level method for removing data from the API
        """

        model = type(instance)

        # Only API.spaces and API.event should not provide
        # the `space argument
        if space is None and model not in (Space, Event):
            raise Exception(
                'In general, `API._delete_json` should always '
                'be called with a `space` argument.'
            )

        if not extra_params:
            extra_params = {}

        if not id_field:
            id_field = 'number'

        if not instance.get(id_field, None):
            raise AttributeError(
                '%s does not have a value for the id field \'%s\'' % (
                    instance.__class__.__name__,
                    id_field
                )
            )

        # Generate the url to hit
        url = '{0}/{1}/{2}/{3}{4}.json?{5}'.format(
            settings.API_ROOT_PATH,
            settings.API_VERSION,
            rel_path or model.rel_path,
            instance[id_field],
            append_to_path or '',
            urllib.urlencode(extra_params),
        )

        # Fetch the data
        response = requests.delete(
            url=url,
            headers={
                'X-Api-Key': self.key,
                'X-Api-Secret': self.secret,
                'Content-type': "application/json",
            },
        )

        if response.status_code == 204:  # OK
            return True
        else:  # Most likely a 404 Not Found
            raise Exception(
                'Code {0} returned from `{1}`. Response text: "{2}".'.format(
                    response.status_code,
                    url,
                    response.text
                )
            )