KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
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?
Tags (comma-separated)
Save Edits
Cancel