How to use Django Models in Javascript with AngularJS
<p>I'm working with django and AngularJS and I want to use my objects I create in Django in my javascript file. </p>

<p>in my models.py (django) I make my object:</p>

<pre><code>from django.db import models


class Cashflow(models.Model):
    index = models.FloatField();
    value = models.FloatField();
    date = models.DateField();
</code></pre>

<p>In my js file I want to use it like:</p>

<pre><code>app = angular.module("coco",[]);

app.controller('cocoCtrl',['$scope',function($scope){

$scope.newCashflow = new Cashflow()

$scope.save = function(cashflow){
        $scope.newCashflow.index = cashflow.index;
        $scope.newCashflow.value = cashflow.value;
        $scope.newCashflow.date = cashflow.date;
</code></pre>

<p>....</p>

<p>but that doesn't work.. Do I forget something? I get no errors or logs but just nothing happens</p>

<p>you need to change the model object to Json object by serializing first.</p>

<p>I can show some code for you.</p>

<pre><code>results = []
    objects = one_table.object.all()
for i in objects:
   results.append({'field1: i.value1', 'field2': i.value2})

return HttpResponse(json.dumps(results))
</code></pre>

javascript python angularjs django