आप एक सरणी (वास्तव में, एक शब्दकोश) इस तरह से है कि यह
<table>
<tr>
<th>header1</th>
<th>header2</th>
<th>header3</th>
<th>header4</th>
</tr>
{% for r in result %}
<tr>
<th> {{ result.name }}</th>
<th> {{ result.address }}</th>
<th> {{ result.time }}</th>
<th> {{ result.date }}</th>
</tr>
{% endfor %}
</table>
प्रदान की तरह कुछ का निर्माण करने के
result['name']
result['address']
result['time']
result['date']
return render_to_response("my_template.html", {'result:result'})
एक संख्या हैं ऐसा करने की जरूरत है। यह सबसे सरल तरीका है। Django टेम्पलेट टैग प्रलेखन को देखो।
यहां तकनीक की एक सूची है जो मैंने सीखा है। और भी हैं, लेकिन मेरे पास उन सभी को दस्तावेज करने का समय नहीं है। http://binarybugs01.appspot.com/entry/template-iteration-techniques
कभी-कभी आपको टेम्पलेट में जा रहे संदर्भ शब्दकोश से सावधान रहना होगा। आप इस
result = {'name': 'John', 'time': '12/2/2012'....etc}
context['result'] = result
return render_to_response("my_template.html", context}
आप result.result
से अधिक पुनरावृत्ति कर रहे हैं गुजर रहे हैं और चाबियाँ हैं result.result.name
मैं भी तुम्हें याद दिलाना है कि आप या तो एक सूची, एक सेट, एक शब्दकोश है, चाहते हैं या एक tuple.You सरणी आयात कर सकते हैं और इसका उपयोग, हालांकि।
अच्छी चाल। अब मैं इसे बचा रहा हूँ। नई बात सीखना! – CppLearner
धन्यवाद, जैसा कि मुझे चाहिए वैसे ही काम करता है। इसकी प्रशंसा करना। –