testlistはオブジェクトのリストです。例えばテンプレートでフィルタを使用しようとすると、TemplateSyntaxErrorが発生する
testlist.0.name
は、私はそこtemp.htmlファイル内にあり、base.htmlがすべてで正常に動作し、すべてのファイルtemp.html
{% extends 'base.html' %}
{% block content %}
{{testlist.0.name | safe}}
{% endblock %}
を持って、単に "Test3は"
ですそれを使用する他の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テンプレートでフィルタを使用することはできないようです。私は他のフィルターを試して、同じことをやっています。 パイプ文字を使用できるいくつかのオプションがありませんか?それは "|"私のmacbook proのキーはパイプ文字ではなく、djangoが認識できない他の文字ですか?
これはありがとうございました。それは1時間私を夢中にされた – panosmm
さて、それを行う方法を考え出した、もう一度ありがとう。私はこれで新しいです:) – panosmm