Django Template - iterating through nested dictionary - too many examples
I have a call to an external data source that successfully returns a
dictionary in this format. There can be any number of entries:
{
'0090000': {'status': 'some status', 'modified_date':
'2013-08-09T14:23:32Z', 'modified_by': 'John Doe', 'severity': '3
(Normal)', 'created_by': 'Dan Smith', 'summary': "some status",
'created_date': '2013-07-18T21:10:36Z'},
'0060000': {'status': 'some status', 'modified_date':
'2013-06-24T03:19:01Z', 'modified_by': 'Jay Johnson', 'severity': '4
(Low)', 'created_by': 'Tony Thompson', 'summary': "some other status",
'created_date': '2012-05-03T17:45:19Z'}...
}
I'm pulling this data end using some information gathered in a form. I've
read a ton of docs and examples of how to iterate through this and present
the data in a template but I can't quite make it work.
My view is as follows:
def agenda_detail(request, agenda_id):
#get the meeting data
a_data = get_object_or_404(meetingEvent, pk=agenda_id)
#get the DEE data for the VAT fieldset
account_id = a_data.account_number.pk
#get the stored session user/pass
username = request.session['username']
password = request.session['password']
dee_data = onsiteEngineer.objects.filter(account=account_id)
#now we get the case data from the Portal API
portal_raw = CustomerInformation()
customer_data = portal_raw.getOpenCaseInfo(account_id,username,password)
return render_to_response('agendas/detail.html',{'a_data':a_data,
'dee_data': dee_data, 'customer_data': customer_data.iteritems()},
context_instance=RequestContext(request))
My template code dealing with this is (I don't care about the html
formatting right now, i just want to see the data on the screen:
{% for key, value in customer_data.items %}
<p>{{ key }}</p>
{% for info in value %}
{{ value }}
{% endfor %}
{% endfor %}
It's showing no data. I've tried multiple combinations (using .items,
using iteritems, etc.) but I can't quite get it to work.
All advice appreciated.
No comments:
Post a Comment