Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6766517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:50:26+00:00 2026-05-26T14:50:26+00:00

My dictionary looks like this(Dictionary within a dictionary): {‘0’: { ‘chosen_unit’: <Unit: Kg>, ‘cost’:

  • 0

My dictionary looks like this(Dictionary within a dictionary):

{'0': {
    'chosen_unit': <Unit: Kg>,
    'cost': Decimal('10.0000'),
    'unit__name_abbrev': u'G',
    'supplier__supplier': u"Steve's Meat Locker",
    'price': Decimal('5.00'),
    'supplier__address': u'No\r\naddress here',
    'chosen_unit_amount': u'2',
    'city__name': u'Joburg, Central',
    'supplier__phone_number': u'02299944444',
    'supplier__website': None,
    'supplier__price_list': u'',
    'supplier__email': u'ss.sss@ssssss.com',
    'unit__name': u'Gram',
    'name': u'Rump Bone',
}}

Now I’m just trying to display the information on my template but I’m struggling. My code for the template looks like:

{% if landing_dict.ingredients %}
  <hr>
  {% for ingredient in landing_dict.ingredients %}
    {{ ingredient }}
  {% endfor %}
  <a href="/">Print {{ landing_dict.recipe_name }}</a>
{% else %}
  Please search for an ingredient below
{% endif %}

It just shows me ‘0’ on my template?

I also tried:

{% for ingredient in landing_dict.ingredients %}
  {{ ingredient.cost }}
{% endfor %}

This doesn’t even display a result.

I thought perhaps I need to iterate one level deeper so tried this:

{% if landing_dict.ingredients %}
  <hr>
  {% for ingredient in landing_dict.ingredients %}
    {% for field in ingredient %}
      {{ field }}
    {% endfor %}
  {% endfor %}
  <a href="/">Print {{ landing_dict.recipe_name }}</a>
{% else %}
  Please search for an ingredient below
{% endif %}

But this doesn’t display anything.

What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:50:27+00:00Added an answer on May 26, 2026 at 2:50 pm

    Lets say your data is –

    data = {'a': [ [1, 2] ], 'b': [ [3, 4] ],'c':[ [5,6]] }

    You can use the data.items() method to get the dictionary elements. Note, in django templates we do NOT put (). Also some users mentioned values[0] does not work, if that is the case then try values.items.

    <table>
        <tr>
            <td>a</td>
            <td>b</td>
            <td>c</td>
        </tr>
    
        {% for key, values in data.items %}
        <tr>
            <td>{{key}}</td>
            {% for v in values[0] %}
            <td>{{v}}</td>
            {% endfor %}
        </tr>
        {% endfor %}
    </table>
    

    Am pretty sure you can extend this logic to your specific dict.


    To iterate over dict keys in a sorted order – First we sort in python then iterate & render in django template.

    return render_to_response('some_page.html', {'data': sorted(data.items())})

    In template file:

    {% for key, value in data %}
        <tr>
            <td> Key: {{ key }} </td> 
            <td> Value: {{ value }} </td>
        </tr>
    {% endfor %}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got this python dictionary mydict, containing arrays, here's what it looks like :
I have a dictionary that looks like this MyCount= {u'10': 1, u'1': 2, u'3':
Let's suppose I have a Winforms app with a Dictionary that looks like this:
I have a dictionary that looks something like this test1 : 123 test2 :
i have one dictionary that has entries that looks like this: dictionary[ABC.123] = Test
I have a dictionary that looks like this Dictionary<string,string[]> I also have 2 dropdownlist.
I use Boost.Serialization to serialize a std::map. The code looks like this void Dictionary::serialize(std::string
Basically my dictionary looks like: object:[NSNumber numberWithBool:] key: [NSNumber numberWithInteger:ID] I want to add
I have a message definition file that looks like this struct1 { field=name type=string
I've got a group of data that looks like this: 001 001 One 001

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.