August 30, 2007
My duh moment – Django and it’s lack of strip filter
Had a total ‘duh’ moment today at work. I wanted to perform the equivalent of Python’s string.strip method on some Django template output.
I looked on the Django documentation site but I couldn’t find a strip filter.
It took me a few minutes of consternation to figure why the developers wouldn’t include such an oft-needed filter.
And then, the aforementioned duh moment, I realized that I could just call {% myvar.strip %} {{ myvar.strip }} — because my output is a string and you can use Django’s dot syntax to call methods, dictionary keys, etc.
Duh, I’m a moron.
So this post is written for Google in the hopes that someone else similarly consternated will find this tidbit and be un-consternated.
Next: One thing I absolutely love about Django’s template loading
Previous: Talking Django at Atlanta Linux Enthusiasts
Related
- Django cache keys: making them safer
- My first Django snippet: Another Memcache status view
- Django developer wanted at ajc.com
-
Ian
-
http://heisel.org Chris
-
Greg
-
Jose
-
http://www.tarmack.eu Bart
-
nate
-
Sam Kuehn
-
Bradley Ayers
-
Bradley Ayers