testlist केवल ऑब्जेक्ट्स की एक सूची है। उदाहरण के लिएTemplateSyntaxError जब भी मैं अपने टेम्पलेट्स में फ़िल्टर का उपयोग करने का प्रयास करता हूं
testlist.0.name
बस "test3"
है मैं एक फ़ाइल temp.html
{% extends 'base.html' %}
{% block content %}
{{testlist.0.name | safe}}
{% endblock %}
सब वहाँ temp.html फ़ाइल और base.html में है सब के साथ ठीक काम करता है है कि है इसका उपयोग करने वाले अन्य html फ़ाइलें
temp.html मुझे
TemplateSyntaxError at /mytests/
Could not parse the remainder: ' | safe' from 'testlist.0.name | safe'
Request Method: GET
Request URL: http://127.0.0.1:8000/mytests/
Django Version: 1.4
Exception Type: TemplateSyntaxError
Exception Value:
Could not parse the remainder: ' | safe' from 'testlist.0.name | safe'
देता है
जब मैं यह करने के लिए बदलने के लिए:
{% extends 'base.html' %}
{% block content %}
{{testlist.0.lastedited |date:"SHORT_DATE_FORMAT" }}
{% endblock %}
यह मेरे
TemplateSyntaxError at /mytests/
could not parse some characters: testlist.0.lastedited| ||date:"SHORT_DATE_FORMAT"
Request Method: GET
Request URL: http://127.0.0.1:8000/mytests/
Django Version: 1.4
Exception Type: TemplateSyntaxError
Exception Value:
Could not parse some characters: testlist.0.lastedited| ||date:"SHORT_DATE_FORMAT"
आप अंदाजा हो देता है। ऐसा लगता है कि मैं अपने django टेम्पलेट्स में किसी भी फ़िल्टर का उपयोग नहीं कर सकता। मैंने अन्य फिल्टर की कोशिश की और अभी भी वही चीज़ मिल गई। क्या मुझे कुछ विकल्प याद आ रहे हैं जो पाइप चरित्र के उपयोग को सक्षम करते हैं? क्या यह हो सकता है कि "|" मेरे मैकबुक समर्थक पर कुंजी पाइप चरित्र नहीं है लेकिन कुछ अन्य चरित्र जो django पहचानने में विफल रहता है?
जो यह था, बहुत बहुत धन्यवाद। यह मुझे एक घंटे – panosmm
ठीक के लिए पागल कर दिया ठीक है, बस यह पता लगाने के लिए कि कैसे किया जाए, धन्यवाद। मैं इस पर नया हूँ :) – panosmm