This is just a very short (and mostly useless on it's own) example of how the built in slugify filter can be used in a Python script to generate slugs. It was pulled from a script I've written to pull in items from Upcoming.org's API.
I post it because "sunturi" posted [Snippet #29](http://www.djangosnippets.org/snippets/29/), which duplicates the functionality of the built-in slugify filter. In the comments of that snippet, santuri (and others) seem to believe that template filters can only be used within templates. This is incorrect, and I think it's important people understand they can be used elsewhere.
sunturi's snippet does remove prepositions from values before slugifying them, so if you need that, his code will work work. But if all you need is slugification, the built-in slugify filter will work fine -- in a Python script, as well as in a template.
Put inside `mysite/templatetags/getattr.py`
Add `mysite` to your `INSTALLED_APPS`
In your template:
{% load getattr %}
{{ myobject|getattr:"theattr,default value" }}
Thanks to pterk for optimizations! \\o/
Finds all ``<code></code>`` blocks in a text block and replaces it with pygments-highlighted html semantics. It tries to guess the format of the input, and it falls back to Python highlighting if it can't decide. This is useful for highlighting code snippets on a blog, for instance.
If you use javascript code with Django-template filter or other related things, it will be not sufficient to qoute string in javascript. This filter escape the string and quote it.
People -- and by "people" I mean Jeff Croft -- often ask about how to split a list into multiple lists (usually for presenting as columns in a template).
These template tags provide two different ways of splitting lists -- on "vertically", and the other "horizontally".
Simplifies using RequestContext in render_to_response.
Simply call the wrapper with request as the first argument, and the rest of the arguments are as normal for render_to_response.
ex: render_response(request, 'foo_list.html', {'foo': Foo.objects.all()})