testlistは、単なるオブジェクトのリストです。例えば
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テンプレートでフィルターを使用できないようです。私は他のフィルターを試しましたが、それでも同じものが得られます。パイプ文字の使用を可能にするいくつかのオプションがありませんか?「|」ということでしょうか 私のmacbookproのキーはパイプ文字ではなく、djangoが認識できない他の文字ですか?