JSON의 id
필드에 장고 템플릿으로 액세스하려고하는데 콜론이 있습니다. 내가 이름없이 성공 콜론을 탈출 시도했습니다Django의 콜론을 사용하여 JSON 키에 액세스 템플릿
"Could not parse the remainder: ':id' from 'result.id.attributes.im:id'".
: 나는 템플릿에 포함 할 때
, 나는 다음과 같은 오류가 발생합니다.
JSON 출력물을 부모, 장고 템플릿을 사용할 때 포함 시켰습니다.
제안 사항? 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
장고 템플릿
<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