title: Django Model Object to Javascript Array
body: <p>This question was asked a few times before, but I'm unable to get results after following the answers.  I have a Django model.  I convert the model to a JSON string:</p>
  
  <pre><code>    from django.core.serializers.json import DjangoJSONEncoder
      from django.core import serializers
      from .models import MonthData
  
      #Returns multiple rows
      monthData = MonthData.objects.filter(project=id)
      #Convert models to JSON string
      monthDataStr = serializers.serialize("json", monthData,cls=DjangoJSONEncoder)
  </code></pre>
  
  <p>In my template, I want to convert the JSON string to a Javascript array:</p>
  
  <pre><code>var monthData = JSON.parse({{monthData|safe}});
  </code></pre>
  
  <p>However Javascript fails to do the conversion.  The JSON resulting string looks as follows:</p>
  
  <pre><code>[  
     {  
        "model":"raidApp.monthdata",
        "pk":3,
        "fields":{  
           "project":1,
           "month":"2017-06-01T00:00:00Z",
           "budgetCost":0.0,
           "forecastCost":385.0,
           "actualCost":0.0,
           "baselineProgress":6.0,
           "plannedProgress":6.0,
           "actualProgress":4.0
        }
     },
     {  
        "model":"raidApp.monthdata",
        "pk":4,
        "fields":{  
           "project":1,
           "month":"2017-07-01T00:00:00Z",
           "budgetCost":261.0,
           "forecastCost":620.0,
           "actualCost":0.0,
           "baselineProgress":11.0,
           "plannedProgress":11.0,
           "actualProgress":8.0
        }
     },
     {  
        "model":"raidApp.monthdata",
        "pk":5,
        "fields":{  
           "project":1,
           "month":"2017-08-01T00:00:00Z",
           "budgetCost":391.0,
           "forecastCost":741.0,
           "actualCost":385.0,
           "baselineProgress":19.0,
           "plannedProgress":19.0,
           "actualProgress":12.0
        }
     },
     {  
        "model":"raidApp.monthdata",
        "pk":6,
        "fields":{  
           "project":1,
           "month":"2017-09-01T00:00:00Z",
           "budgetCost":522.0,
           "forecastCost":868.0,
           "actualCost":500.0,
           "baselineProgress":28.0,
           "plannedProgress":28.0,
           "actualProgress":15.0
        }
     },
     {  
        "model":"raidApp.monthdata",
        "pk":7,
        "fields":{  
           "project":1,
           "month":"2017-10-01T00:00:00Z",
           "budgetCost":652.0,
           "forecastCost":1001.0,
           "actualCost":550.0,
           "baselineProgress":35.0,
           "plannedProgress":34.0,
           "actualProgress":20.0
        }
     },
     {  
        "model":"raidApp.monthdata",
        "pk":8,
        "fields":{  
           "project":1,
           "month":"2017-11-01T00:00:00Z",
           "budgetCost":782.0,
           "forecastCost":1148.0,
           "actualCost":700.0,
           "baselineProgress":40.0,
           "plannedProgress":41.0,
           "actualProgress":25.0
        }
     },
     {  
        "model":"raidApp.monthdata",
        "pk":9,
        "fields":{  
           "project":1,
           "month":"2017-12-01T00:00:00Z",
           "budgetCost":913.0,
           "forecastCost":1275.0,
           "actualCost":800.0,
           "baselineProgress":48.0,
           "plannedProgress":47.0,
           "actualProgress":35.0
        }
     },
     {  
        "model":"raidApp.monthdata",
        "pk":10,
        "fields":{  
           "project":1,
           "month":"2018-01-01T00:00:00Z",
           "budgetCost":1043.0,
           "forecastCost":1408.0,
           "actualCost":900.0,
           "baselineProgress":55.0,
           "plannedProgress":54.0,
           "actualProgress":50.0
        }
     },
     {  
        "model":"raidApp.monthdata",
        "pk":11,
        "fields":{  
           "project":1,
           "month":"2018-02-01T00:00:00Z",
           "budgetCost":1174.0,
           "forecastCost":1500.0,
           "actualCost":1000.0,
           "baselineProgress":60.0,
           "plannedProgress":58.0,
           "actualProgress":52.0
        }
     },
     {  
        "model":"raidApp.monthdata",
        "pk":12,
        "fields":{  
           "project":1,
           "month":"2018-03-01T00:00:00Z",
           "budgetCost":1304.0,
           "forecastCost":1500.0,
           "actualCost":1150.0,
           "baselineProgress":70.0,
           "plannedProgress":67.0,
           "actualProgress":53.0
        }
     },
     {  
        "model":"raidApp.monthdata",
        "pk":13,
        "fields":{  
           "project":1,
           "month":"2018-04-01T00:00:00Z",
           "budgetCost":1396.0,
           "forecastCost":1500.0,
           "actualCost":0.0,
           "baselineProgress":90.0,
           "plannedProgress":85.0,
           "actualProgress":65.0
        }
     },
     {  
        "model":"raidApp.monthdata",
        "pk":14,
        "fields":{  
           "project":1,
           "month":"2018-05-01T00:00:00Z",
           "budgetCost":1500.0,
           "forecastCost":1500.0,
           "actualCost":0.0,
           "baselineProgress":95.0,
           "plannedProgress":90.0,
           "actualProgress":85.0
        }
     },
     {  
        "model":"raidApp.monthdata",
        "pk":15,
        "fields":{  
           "project":1,
           "month":"2018-06-01T00:00:00Z",
           "budgetCost":1500.0,
           "forecastCost":1500.0,
           "actualCost":0.0,
           "baselineProgress":100.0,
           "plannedProgress":100.0,
           "actualProgress":90.0
        }
     },
     {  
        "model":"raidApp.monthdata",
        "pk":16,
        "fields":{  
           "project":1,
           "month":"2018-07-01T00:00:00Z",
           "budgetCost":1500.0,
           "forecastCost":1500.0,
           "actualCost":0.0,
           "baselineProgress":100.0,
           "plannedProgress":100.0,
           "actualProgress":100.0
        }
     },
     {  
        "model":"raidApp.monthdata",
        "pk":17,
        "fields":{  
           "project":1,
           "month":"2018-08-01T00:00:00Z",
           "budgetCost":1500.0,
           "forecastCost":1500.0,
           "actualCost":0.0,
           "baselineProgress":100.0,
           "plannedProgress":100.0,
           "actualProgress":0.0
        }
     }
  ]
  </code></pre>
  
  <p>Is there a standard way to make a Django model JSON string more "Javascript friendly"?  If not, what workarounds are available?</p>
  
  <p>If what I'm trying to do is not best practice, how can I send Django model data to Javascript without having to send row by row or value by value?</p>