1
我試圖訪問id
場JSON在Django模板,但它在其結腸結腸。訪問JSON重點用在Django模板
當我包括在模板中,我得到以下錯誤:
"Could not parse the remainder: ':id' from 'result.id.attributes.im:id'".
我試圖逃避的名稱,並沒有成功結腸。
我已經包含了JSON輸出,當我使用它的父,以及Django模板。
有什麼建議嗎?
* 使用JSON HTML輸出傳遞了當父(result.id.attribute)*
1 id: {**u'im:id': u'422689480'**, u'im:bundleId': u'com.google.Gmail'} Name: Gmail - Google, Inc.
2 id: {u'im:id': u'530755375', u'im:bundleId': u'com.kfactormedia.mycalendarfree'} Name: MyCalendar Free - K-Factor Media, LLC.
3 id: {u'im:id': u'518972315', u'im:bundleId': u'com.click2mobile.textGramFree'} Name: Textgram - Texting with Instagram FREE - click2mobile
4 id: {u'im:id': u'521863802', u'im:bundleId': u'com.appmosys.emoji2free'} Name: Emoji 2 Free - 300+ NEW Emoticons and Symbols - Appmosys
Django的模板
<html>
<body>
{% for result in app_data.entry %}
<h3>
{{ forloop.counter }}
Id: {{ result.id.attributes }}
Name: {{ result.title.label }}
{% endfor %}
</h3>
</body>
</html>
編輯,包括查看:
查看
def findAppRank(request,AppId=424909112):
URL="http://itunes.apple.com/us/rss/topfreeapplications/limit=300/genre=6007/json"
r=requests.get(URL)
output=r.content
data=json.loads(output)
AppData=data['feed']
t=get_template('myrank.html')
html=t.render(Context({'app_data': AppData, 'app_id': AppId }))
return HttpResponse(html)
您能否提供您使用的信息以及如何獲取'app_data'? –
我添加了上面的視圖。如果您有任何問題,請告訴我。 – Rangers4me
我想出了一個解決方案。如果你拉出整個值的數組 - 你可以通過整數而不是名字來選擇它。 「result.id.attributes.values.0」 – Rangers4me