Login

Snippets by hotani

Snippet List

Custom SQL Function; Outputs Template-Friendly Content

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 %}

  • templates
  • custom-sql
Read More

Name Capitalize Filter

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
Read More

hotani has posted 2 snippets.