Login

Snippets by pryankster

Snippet List

Making templatetags global to all templates

I found myself putting `{%load ... %}` in every template that I was writing, so DRY .. I created an app called 'globaltags' and in its `__init__.py`, I just pre-load the tags that I use frequently. The [pyif](http://www.djangosnippets.org/snippets/130/) and [expr](http://www.djangosnippets.org/snippets/9/) tags are excellent tags, and I highly recommend them for getting the most out of django's template language. The [dbinfo](http://www.djangosnippets.org/snippets/159/) snippet is something that I came up with to easily output SQL debugging information.

  • tag
Read More

Template tag to dump database query info

This snippet introduces two tags: `{%dbinfo%}` and `{%dbquerylist%}`. The `{%dbinfo%}` tag returns a string with the # of database queries and aggregate DB time. The `{%dbquerylist%}` tag expands to a set of <LI> elements containing the actual SQL queries executed. If `settings.TEMPLATE_DEBUG` is False, both tags return empty strings.

  • tag
  • db
  • debugging
Read More

pryankster has posted 2 snippets.