'Convenience method for client post which serializes the data into json and sets the accept type
to json'

def ajax_post(self, path, data=None, content_type='application/json', **kwargs):

    if (not isinstance(data, basestring)):
        data = json.dumps((data or {}))
    kwargs.setdefault('HTTP_X_REQUESTED_WITH', 'XMLHttpRequest')
    kwargs.setdefault('HTTP_ACCEPT', 'application/json')
    return self.post(path=path, data=data, content_type=content_type, **kwargs)
