Login

Tag "inclusion-tag"

Snippet List

Template tag to render collections.Counter as an html table

Render a given instance of collections.Counter into a 2 column html table. Optionally accepts `column_title` keyword argument which sets the table key column header. Usage: {% counter_table event_counter column_title='event type' %} The above will render the a table from the `event_counter` variable with the first (key) column set to "event type". See below for an example template (i.e `counter_table.html`) {% load i18n %} <table> <thead> <tr> <th>{{column_title|capfirst}}</th> <th>{% trans "count"|capfirst %}</th> </tr> </thead> <tbody> {% for key, count in most_common %} <tr> <td>{{key}}</td> <td>{{count}}</td> </tr> {% endfor %} </tbody> <tfoot> <tr> <td>{% trans "total"|capfirst %}</td> <td>{{total_count}}</td> </tr> </tfoot> </table>

  • html
  • table
  • inclusion-tag
  • collections.Counter
  • Counter
Read More

Feed Reader Inclusion Tag

This is an inclusion tag that can be used to pull in posts from any feed to a template. It doesn't do any caching, so it may slow down page load times. Depends on [Feedparser](http://www.feedparser.org). Template usage: {% pull_feed 'http://www.djangosnippets.org/feeds/latest/' 3 %}

  • feed
  • rss
  • inclusion-tag
Read More

3 snippets posted so far.