Instead of "for team in {{l}}{{d}}" you should be able to do "for team in
l.d" IIRC.

TBH I haven't tried it and I'm on my phone so I can't run a quick check.
This SO post also has some hints on running nested loops:
http://stackoverflow.com/questions/13870890/django-template-counter-in-nested-loops

-James


On Thursday, September 18, 2014, Joel Goldstick <[email protected]>
wrote:

> I have some embed loops which iterate over league and division.  I
> want to print the teams in each.  I obviously can't do what i tried in
> line 19.  Is there a way to calculate a key to a dictionary I want to
> iterate over?
>
> 14{% for l in leagues %}
> 15 <h3>{{l}}</h3>
> 16 {% for d in divisions %}
> 17 <h4>{{d}}</h4>
> 18 <table>
> 19 {% for team in {{l}}{{d}} %}
> 20 <tr><td>{{team}}</td><td> {{ team.wins }}-</td><td>{{ team.losses
> }}</td> </li>
> 21 {% endfor %}
>
> Here is my context:
>
> {u'ALW': [<Team: Oakland Athletics 1975>, <Team: Kansas City Royals
> 1975>, <Team: Texas Rangers 1975>, <Team: Minnesota Twins 1975>,
> <Team: Chicago White Sox 1975>, <Team: California Angels 1975>],
> u'ALE': [<Team: Boston Red Sox 1975>, <Team: Baltimore Orioles 1975>,
> <Team: New York Yankees 1975>, <Team: Cleveland Indians 1975>, <Team:
> Milwaukee Brewers 1975>, <Team: Detroit Tigers 1975>], u'NLE': [<Team:
> Pittsburgh Pirates 1975>, <Team: Philadelphia Phillies 1975>, <Team:
> New York Mets 1975>, <Team: St. Louis Cardinals 1975>, <Team: Chicago
> Cubs 1975>, <Team: Montreal Expos 1975>], u'NLW': [<Team: Cincinnati
> Reds 1975>, <Team: Los Angeles Dodgers 1975>, <Team: San Francisco
> Giants 1975>, <Team: San Diego Padres 1975>, <Team: Atlanta Braves
> 1975>, <Team: Houston Astros 1975>]}
> {'leagues': [u'AL', u'NL'], u'NLE': [<Team: Pittsburgh Pirates 1975>,
> <Team: Philadelphia Phillies 1975>, <Team: New York Mets 1975>, <Team:
> St. Louis Cardinals 1975>, <Team: Chicago Cubs 1975>, <Team: Montreal
> Expos 1975>], u'NLW': [<Team: Cincinnati Reds 1975>, <Team: Los
> Angeles Dodgers 1975>, <Team: San Francisco Giants 1975>, <Team: San
> Diego Padres 1975>, <Team: Atlanta Braves 1975>, <Team: Houston Astros
> 1975>], 'year': u'1975', u'ALW': [<Team: Oakland Athletics 1975>,
> <Team: Kansas City Royals 1975>, <Team: Texas Rangers 1975>, <Team:
> Minnesota Twins 1975>, <Team: Chicago White Sox 1975>, <Team:
> California Angels 1975>], u'ALE': [<Team: Boston Red Sox 1975>, <Team:
> Baltimore Orioles 1975>, <Team: New York Yankees 1975>, <Team:
> Cleveland Indians 1975>, <Team: Milwaukee Brewers 1975>, <Team:
> Detroit Tigers 1975>], 'divisions': [u'E', u'W']}
>
> --
> Joel Goldstick
> http://joelgoldstick.com
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected] <javascript:;>.
> To post to this group, send email to [email protected]
> <javascript:;>.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAPM-O%2ByfS1BfDCEKYbJOwctjtd8JkJ04OS71iv4dVtVRQf8KRA%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciV2AysQkXhmhzt1yXa-afxCR1QGRB2icXdVPXT4CZ6N2w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to