JSON combined with python loop to only print integers
<p>I'm trying to loop through integers that are in the json list based on a variable provided before. Here is my JSON list:</p>

<pre><code>    tracks =[
   {
      'album_name':'Nevermind',
      1:'Smells like teen spirit',
      2:'In Bloom',
      3:'Come as you are',
      4:'Breed',
      5:'Lithium',
      6:'Polly',
      7:'Territorial Pissings',
      8:'Drain You',
      9:'Lounge act',
      10:'Stay away',
      11:'On a plain',
      12:'Something in the way'
   },
   {
      'album_name':'Relapse',
      1:'Hello',
      2':'3AM',

   },

]
</code></pre>

<p>And this is my html loop:</p>

<pre><code>&lt;div class="single_album"&gt;
    &lt;h2&gt;Track list&lt;/h2&gt;
    {% for tracks in tracks if tracks.album_name == album_name %}
        &lt;ol&gt;
            &lt;li&gt;{{ tracks[x] }}&lt;/li&gt;
        &lt;/ol&gt;
    {% endfor %}
&lt;/div&gt;
</code></pre>

<p>If I put 1 instead of 'x' it works, as it prints record number one which is "1:'Smells like teen spirit'" However I don't know how to make a loop in which the x will increment each time it loops as I Im not sure whether it should be placed in python or html file.</p>

<pre><code>In [15]: from django.template import Template,Context    
In [16]: tracks =[
        ...:    {
        ...:       'album_name':'Nevermind',
        ...:       1:'Smells like teen spirit',
        ...:       2:'In Bloom',
        ...:       3:'Come as you are',
        ...:       4:'Breed',
        ...:       5:'Lithium',
        ...:       6:'Polly',
        ...:       7:'Territorial Pissings',
        ...:       8:'Drain You',
        ...:       9:'Lounge act',
        ...:       10:'Stay away',
        ...:       11:'On a plain',
        ...:       12:'Something in the way'
        ...:    },
        ...:    {
        ...:       'album_name':'Relapse',
        ...:       1:'Hello',
        ...:       2:'3AM',
        ...:
        ...:    },
        ...:
        ...: ]

    In [17]: t = Template("""&lt;div class="single_album"&gt; &lt;h2&gt;Track list&lt;/h2&gt; {% for track in tracks %} {%if track.album_name == album_name %}&lt;ol&gt; {% for key, value in track
        ...: .items %} {%if key != 'album_name' %}&lt;li&gt;{{value}}&lt;/li&gt;{%endif%} {% endfor%} &lt;/ol&gt;{%endif%} {% endfor %} &lt;/div&gt;""")

    In [18]: c = Context({"tracks": tracks,'album_name':'Nevermind'})

    In [19]: t.render(c)
    Out[19]: u'&lt;div class="single_album"&gt; &lt;h2&gt;Track list&lt;/h2&gt;  &lt;ol&gt;  &lt;li&gt;Smells like teen spirit&lt;/li&gt;  &lt;li&gt;In Bloom&lt;/li&gt;  &lt;li&gt;Come as you are&lt;/li&gt;  &lt;li&gt;Breed&lt;/li&gt;  &lt;li&gt;Lithium&lt;/li&gt;  &lt;li&gt;Polly&lt;/li&gt;  &lt;li&gt;Territorial Pissings&lt;/li&gt;  &lt;li&gt;Drain You&lt;/li&gt;  &lt;li&gt;Lounge act&lt;/li&gt;  &lt;li&gt;Stay away&lt;/li&gt;  &lt;li&gt;On a plain&lt;/li&gt;  &lt;li&gt;Something in the way&lt;/li&gt;    &lt;/ol&gt;    &lt;/div&gt;'

    In [20]:
</code></pre>

python loops count increment