Template Filter - stringformat issue

24 views
Skip to first unread message

DieHardMan 300

unread,
Mar 14, 2023, 9:23:07 AM3/14/23
to Django users
I tried Django template built-in filter "stringformat" to fixed string length to 3 for example assume I have variable name "data" contain "A1" I want to display this variable as "A1 " (1 blank space) so my code is
{{ data|stringformat:":<3s" }}  --> Result is None
so I tried another 6 examples
{{ data|stringformat:":<3" }}  --> Result is None
{{ data|stringformat:"{:<3}" }}  --> Result is None
{{ data|stringformat:":3" }}  --> Result is None
{{ data|stringformat:"{:3}" }} --> Result is None
{{ data|stringformat:":<3s" }} --> Result is None
{{ data|stringformat:"3s" }} --> Result is "A1" not "A1 "
I'm not sure what I'm missing, I cannot find answer online if anyone could help I would be appriciate.
Reply all
Reply to author
Forward
0 new messages