0

POST http://api.link/api/v1/articlerevision 404 (NOT FOUND)

当我尝试通过 AngularJS 和 Django-Tastypie API 添加新项目时,出现以下错误。如果我在浏览器中打开链接,它可以工作,我打赌当我提交表单时,它不会。我已经开始allowed_methodsget, put, post, delete,但这似乎没有解决任何问题。还有什么其他选择?

编辑:

视图.tpl.html

<div ng-controller="CreateCtrl">
    <form class="form-horizontal">
        <fieldset>
            <label>
            Title
            <input class="form-control" type="text" ng-model="revision.title" placeholder="Title">
            </label>

            <br />

            <label>
            Description
            <textarea class="form-control" type="text" ng-model="revision.content"></textarea>
            </label>

            <button ng-click="create()">Save</button>
        </fieldset>
    </form>
</div>

var tastypieDataTransformer = function ($http) {
    return $http.defaults.transformResponse.concat([
        function (data, headersGetter) {
            var result = data.objects;
            result.meta = data.meta;
            return result;
        }
    ]);
};

bosApp.factory('Revision', function($resource, $http) {
    return $resource('http://api.link/api/v1/articlerevision/:id/', {
            id: '@is'
        },
        {
            update: {
                method: 'POST',
                params: {"update": true},
                isArray: false
            },
            save: {
                method: 'PUT'
            },
            query: {
                method: 'GET',
                isArray: true,
                transformResponse: tastypieDataTransformer($http)
            },
            create: {
                method: 'POST'
            }
        }
    );
});

var CreateCtrl = function($scope, $location, Revision) {
    $scope.create = function() {
        Revision.create($scope.revision);
    };
};
4

0 回答 0