Django Environmental Based Settings

Here's another small and easy Django tip, but one that I had a hard time finding an answer to when I first got started... I came from a Ruby on Rails and Groovy/Grails background before starting with Django. One thing both of those frameworks have is the concept of environments. Depending on what you're doing, you can have one of 3 environments going:

Escaping data inside django template tags

This may be something that most people know, but I had a hard time tracking this down for some reason.

I have a couple of custom template tags that do things like get twitter feeds or my github commits. Some of them are simple inclusion tags and don't need this, however, I do have one tag that gets some data and spits it out formatted. Now, I know this may not be the best possible solution to the problem and I will eventually go back and fix this code to do something else, but for now, I wanted to make sure that the data that was being formatted inside of the template tag was being escaped so that I could avoid any XSS issues that could potentially arise.

[more...]

page: 1 of 1