Saturday, May 29, 2010

how to show blank spaces at the start of string in django templates

Hi

I formated with python numbers like e.g.:

" 3457.50"
" 11450.25"

but my problem is to show them correctly one below the other
in a column by django templates
because the blank spaces are ignored.
I tried with the filter escape, however it does not work.

A solution would be to loop over the characters in string like:

<td>{% for c in number_string %}{% if c == ' ' %}&nbsp;{% else %}{{ c }}{% endif %}{% endfor %}</td>

and so to replace blank space with &nbsp; but this is very cumbersome.

Can somebody tell me if we here have a simple and elegant solution?
Thanks in advance and best regards
Ogi

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment