我认为我有一个列表,例如
getit = [{u'company': u'',
u'customerId': u'qwert',
u'dateCreated': u'2012-10-28 08:52:43.0',
u'dateModified': u'2012-12-17 22:27:58.0',
u'email1': u'',
u'email2': u'',
u'extensionId': u'306',
u'message': u'',
u'name': u'',
u'phone1': u'0284533',
u'phone2': u'',
u'productCode': u'12400',
u'prospectId': u'795',
u'status': u'0',
u'subscriberEmail': u'naveen@hi.com',
u'subscriberId': u'ro@gmail.com',
u'title': u'',
u'trackId': u'12345',
u'vendorEmail': u'va@tal.com',
u'vendorNumber': u'0284533'}]
context['hi'] = getit
我正在尝试在我的模板中迭代这些数据,例如 .
{% for x in hi %}
{{x.status}}
{{x.productCode}}
{% endfor %}
不幸的是无法在我的模板中访问
请帮我看看我在这里做错了什么
*更新*
这是我的看法
def subscriberreport(request):
context = {}
subscriberId = request.session['subscriberId']
REST_URL = 'http://10.10.10.76:8100/UCSRestService/prospectrequest/' + subscriberId + '/subscriber'
context = {}
geta = Agent()
getr = geta.GETT('caason',REST_URL,'apikey','SecretString')
geti = geta.response.text
getwj = json.loads(geti)
for i,j in getwj.items():
if i == "data":
getit = j
print getit
print type(getit)
context['hi'] = getit
RESTC_URL = 'http://10.10.10.76:8100/UCSRestService/calldetailrecord/' + subscriberId + '/subscriber'
context = {}
getac = Agent()
getrc = getac.GETT('caason',RESTC_URL,'apikey','SecretString')
getic = getac.response.text
getwjc = json.loads(getic)
print "++++++++++++++++++++++CDR+"
for k,v in getwjc.items():
if k == "data":
context['cdr'] = v
if k == "error":
context['cdr'] = False
context['report'] = True
return render_to_response('actual/reports.html', context, context_instance=RequestContext(request))