views:

368

answers:

1

Hay, I'm writing some templates but i want to convert " " into "_" within a string.

I want to convert

{{ user.name }}

Which outputs "My Name"

to "My_Name"

how do i do this?

Thanks

+2  A: 

There is no built-in tag or filter to do this replacement. Write a filter that splits by a given character, and then combine that with the join filter, or write a filter that does the replacement directly.

Ignacio Vazquez-Abrams
http://docs.djangoproject.com/en/dev/howto/custom-template-tags/
jcdyer
Seems that i cannot use custom filters with a inclusion, any ideas?
dotty
note toself: user {% load %} again!
dotty