render dictionary with in dictionary

I have added a method to meta.py in views. Method is very similar to existing badge method. it returns following data structure:

(Pdb) print d

    {'badge-1': {'badge_recipients': [<User: NNN>], 'badge': <BadgeData: gold: badge-2>, 'page_class': 'meta'}, 'badge-2': {'badge_recipients': [<User: aa>, <User: NNN>, <User: admin>, <User: Test>, <User: bbb>], 'badge': <BadgeData: bronze: badge-1>, 'page_class': 'meta'}}

I want to simply render this and present as a list:

current badge.html has following:

<div id="award-list">
    {% for recipient in badge_recipients %}
        <div class="user">
                <span class="thumb">{{ gravatar(recipient, 32) }}</span>
                <span><a href="{{ recipient.get_absolute_url() }}">{{recipient.username|escape}}</a></span>
                <span>{{ macros.user_score_and_badge_summary(user) }}</span>
        </div>
    {% endfor %}
</div>

how can I change this to print the users as a list based on the badge I like to render as follows:

Badge 1 Wiinners
   user a
   user b
Badge 2 Winners
   user b
SocialQA's avatar
265
SocialQA
asked 2014-03-25 16:35:49 -0600, updated 2014-03-25 16:36:53 -0600
edit flag offensive 0 remove flag close merge delete

Comments

1

Probably you will need to have a nested loop in your template.

Evgeny's avatar Evgeny (2014-03-25 19:11:03 -0600) edit

What I am confuse is that badge view returns data = {} dictionary and directly accessing the badge_recipients list. I tried to do for key, value in d.iteritems(): but nothing got render.

SocialQA's avatar SocialQA (2014-03-25 19:47:48 -0600) edit
add a comment see more comments