<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_object(self, request):
 """ Adds an object. """

        try:
            # backbone sends data in the body in json format
            # Conditional statement is for backwards compatibility with Django <= 1.3
            data = json.loads(request.body if hasattr(request, 'body') else request.raw_post_data)
        except ValueError:
            return HttpResponseBadRequest(_('Unable to parse JSON request body.'))

        form = self.get_form_instance(request, data=data)
        if form.is_valid():
            if not self.has_add_permission_for_data(request, form.cleaned_data):
                return HttpResponseForbidden(_('You do not have permission to perform this action.'))

            obj = form.save()

            # We return the newly created object's details and a Location header with it's url
            response = self.get_object_detail(request, obj)
            response.status_code = 201

            opts = self.model._meta
            url_slug = self.url_slug or (
                opts.model_name if hasattr(opts, 'model_name') else opts.module_name
            )
            url_name = 'backbone:%s_%s_detail' % (self.model._meta.app_label, url_slug)
            response['Location'] = reverse(url_name, args=[obj.id])
            return response
        else:
            return HttpResponseBadRequest(self.json_dumps(form.errors), content_type='application/json')