title: Django pass Python Object from view to Javascript script in template
body: <p>This is a simple  code created only to show the probem,
  obviusly the task that this simple code is trying to do can be done without Javascript, but I need to know how I can do this using Javascript, because
  In my real code I need it, and It cant't be done without Javascript 
  (basically I create a dinamic 2D array with information from the view)</p>
  
  <p>in view.py</p>
  
  <p>in def play_game function </p>
  
  <pre><code>...
  players = Player.objects.all()
  context = {
      'players' : players
  }
  return render(request,'play_game.html', context)
  </code></pre>
  
  <p>in model.py</p>
  
  <pre><code>  class Player(models.Model):
  
      game = models.ForeignKey(Game, on_delete=models.CASCADE, blank=True, null=True)
      loose = models.IntegerField( default=0)
      win = models.IntegerField(default=0)
      name = models.CharField(max_length=9)
  </code></pre>
  
  <p>In play_game.html</p>
  
  <pre><code> &lt;script&gt;
  var players = "{{players}}";
  for (player in players) {
      document.write(player.name);
      document.write("  Win:"+ player.win); 
      document.write("Loose: " + player.loose); 
  };
  &lt;/script&gt;
  </code></pre>