Snippet List
This will return a template-friendly list of dictionaries when using custom SQL. The dictionary can be accessed just as a normal model/queryset.
Example of use (in view):
qkeys = ['artist','album']
query = """
SELECT "artist","album" FROM "music"
"""
new_list = csql(request,query,qkeys)
(in template)
{% for row in new_list %}
{{ row.artist }} {{ row.album }}
{% endfor %}
This is to be used as a template filter. See [django documentation](http://www.djangoproject.com/documentation/templates_python/#writing-custom-template-filters) for adding custom filters.
Example of use:
name = "bart simpson"
`{{ name|cap }}` will convert 'name' to "Bart Simpson"
It works on space-separated names, as well as the following:
* converts "mcfly" to "McFly";
* converts "o'neill" to "O'Neill";
* converts "barker-bradley" to "Barker-Bradley"
- names
- template-filters
- capitalize
hotani has posted 2 snippets.