1

Django-rest-framework を使用してデータを公開している Django アプリケーションがあります。次のように、json 形式でオブジェクトにアクセスできます。

curl http://localhost:8000/cemeteries/

また

curl http://localhost:8000/cemeteries/2/

私は現在、データにアクセスするために AngularJS を使用しようとしています。私はそのようにrestangularを設定しました:

demoApp.factory('CbgenRestangular', function(Restangular) {
        return Restangular.withConfig(function(RestangularConfigurer) {
            RestangularConfigurer.setBaseUrl('http://localhost:8000');
        });
    });

そして、私のコントローラーで:

 demoApp.controller('SimpleController', function($scope, simpleFactory, CbgenRestangular, $location){
        $scope.customers = [];

        CbgenRestangular.all("cemeteries/").getList().then(function() {
          console.log("All ok");
        }, function(response) {
          console.log("Error with status code", response.status);
        });

問題は、Django ログに常に HTTP OPTIONS リクエストが表示されることです。

[14/Aug/2013 12:24:12] "OPTIONS /cemeteries/ HTTP/1.1" 200 10245

Firebug では、「ステータス コード 0 のエラー」と表示されます。

私は何が間違っているのですか?よろしくお願いします。

よろしく、フィル

4

1 に答える 1