I am looking for a way to pass data to the index.js script from django view. Sample simple view:
   def map_display(request):
        data = [
        {'lat': 52.20415533, 'lng': 21.01427746},
        {'lat': 52.20418, 'lng': 21.014386},
        ]
        data = json.dumps(data)
        return render(request, 'index.html', {"data": data} )
How to pas list data to flightPlanCoordinates variable?
index.js
function initMap() {
  const map = new google.maps.Map(document.getElementById("map"), {
    zoom: 3,
    center: { lat: 0, lng: -180 },
    mapTypeId: "terrain",
  });
  const flightPlanCoordinates = {{ data}};  # <--- pass here
  const flightPath = new google.maps.Polyline({
    path: flightPlanCoordinates,
    geodesic: true,
    strokeColor: "#FF0000",
    strokeOpacity: 1.0,
    strokeWeight: 2,
  });
  flightPath.setMap(map);
}
index.html
<html>
  <head>
    <title>Simple Polylines</title>
    <script src="https://polyfill.io/v3/polyfill.min.js?features=default"></script>
    <link href= "{% static 'css/style.css' %}"  rel="stylesheet" type="text/css">
    <script src="{% static 'js/index.js' %}" ></script>
  </head>
  <body>
    <div id="map"></div>
    <script
      src="https://maps.googleapis.com/maps/api/js?key=........=initMap&libraries=&v=weekly"
      async
    ></script>
  </body>
</html>
 
    