0
私はhtmlテーブルに変換したい2次元JSONを持っています。このようなもの:http://www.bogotobogo.com/AngularJS/AngularJS_Tables.php角型JS変換2 dim JSON in django
シリアライズについては聞いたことがありますが、これはあまり効果がありません。そしてそれはどのように働くでしょうか?
[{"model": "pricing.cashflow", "pk": 1, "fields": {"value": 4.0, "date": "2016-09-09"}}, {"model": "pricing.cashflow", "pk": 2, "fields": {"value": 3.0, "date": "2016-09-01"}}, {"model": "pricing.cashflow", "pk": 3, "fields": {"value": 3.0, "date": "2016-09-01"}}, {"model": "pricing.cashflow", "pk": 4, "fields": {"value": 3.0, "date": "2016-09-01"}}, {"model": "pricing.cashflow", "pk": 5, "fields": {"value": 3.0, "date": "2016-09-01"}}, {"model": "pricing.cashflow", "pk": 6, "fields": {"value": 5.0, "date": "2016-09-07"}}, {"model": "pricing.cashflow", "pk": 7, "fields": {"value": 3.0, "date": "2016-09-28"}}, {"model": "pricing.cashflow", "pk": 8, "fields": {"value": 3.0, "date": "2016-09-22"}}, {"model": "pricing.cashflow", "pk": 9, "fields": {"value": 5.0, "date": "2016-09-16"}}, {"model": "pricing.cashflow", "pk": 10, "fields": {"value": 5.0, "date": "2016-09-16"}}, {"model": "pricing.cashflow", "pk": 11, "fields": {"value": 4.0, "date": "2016-09-08"}}, {"model": "pricing.cashflow", "pk": 12, "fields": {"value": 8.0, "date": "2016-09-22"}}, {"model": "pricing.cashflow", "pk": 13, "fields": {"value": 3.0, "date": "2016-09-22"}}, {"model": "pricing.cashflow", "pk": 14, "fields": {"value": 5.0, "date": "2016-09-01"}}, {"model": "pricing.cashflow", "pk": 15, "fields": {"value": 8.0, "date": "2016-09-01"}}, {"model": "pricing.cashflow", "pk": 16, "fields": {"value": 4.0, "date": "2016-09-08"}}, {"model": "pricing.cashflow", "pk": 17, "fields": {"value": 5.0, "date": "2016-09-09"}}, {"model": "pricing.cashflow", "pk": 18, "fields": {"value": 5.0, "date": "2016-09-09"}}, {"model": "pricing.cashflow", "pk": 19, "fields": {"value": 5.0, "date": "2016-09-09"}}, {"model": "pricing.cashflow", "pk": 20, "fields": {"value": 3.0, "date": "2016-09-16"}}, {"model": "pricing.cashflow", "pk": 21, "fields": {"value": 3.0, "date": "2016-09-16"}}, {"model": "pricing.cashflow", "pk": 22, "fields": {"value": 3.0, "date": "2016-09-16"}}, {"model": "pricing.cashflow", "pk": 23, "fields": {"value": 3.0, "date": "2016-09-16"}}, {"model": "pricing.cashflow", "pk": 24, "fields": {"value": 3.0, "date": "2016-09-16"}}, {"model": "pricing.cashflow", "pk": 25, "fields": {"value": 8.0, "date": "2016-09-29"}}, {"model": "pricing.cashflow", "pk": 26, "fields": {"value": 3.0, "date": "2016-09-18"}}, {"model": "pricing.cashflow", "pk": 27, "fields": {"value": 4.0, "date": "2016-09-25"}}, {"model": "pricing.cashflow", "pk": 28, "fields": {"value": 4.0, "date": "2016-09-25"}}, {"model": "pricing.cashflow", "pk": 29, "fields": {"value": 4.0, "date": "2016-09-25"}}]
ビュー:
def get_cashflows(request):
return HttpResponse(
serializers.serialize("json", Cashflow.objects.all()),
content_type="application/json"
)
JS
app.controller('cocogetCtrl',['$scope','$http', function($scope,$http) {
$scope.getData = function(){
$http.get("/getcashflow/")
.success(function(data) {
});
});
};
setInterval($scope.getData, 1000);
}]);
(あなたの)レスポンス=データ? – Coding
それは動作します!どうもありがとう! – Coding
あなたの歓迎!あなたの質問に答えた場合は、受け入れられたと答えてください。 – cnorthfield