0
長すぎる文字を埋めて切り取りたい。だから、私はstringformatを使いました。この例では、文字列を10文字にし、必要に応じてパディングを追加します。私はこのコードを私のdjangoテンプレートに持っています。djangoテンプレートの文字列書式
{{ "my too long or too short string"|stringformat:":10" }}
しかし、djangoは何も出力しません。で、エージェントbulit truncatechars
テンプレートタグ
{{ "my too long or too short string"|truncatechars:10 }}
使用は、あなたが[カスタムテンプレートフィルタ](https://docs.djangoproject.com/en/1.10/howto/custom-template-tags/を作成することを検討していました
–