I have a TemplateColumn in a django-tables2 table and I want to use a custom template filter (named int_to_time) to transform the data. When I use a built in filter it works fine.
What I have done until now is that I’ve copied the templates\django_tables2\table.html from django-tables2 to my project and included my tag library to table.html.
However, when I try to render my view, I get the following error:
TemplateSyntaxError at /details_show/2012/3/13/2 Invalid filter: 'int_to_time'
The error seems to be in line 28 of table.html
{% for column, cell in row.items %}
I can confirm that my tag library is loading because if for instance I write the name of the tag library wrong then I will get a Template library not found error.
Please help !
Simplest solution
TemplateColumnrenders the column externally to the template. Any custom filters or tags you load in the template won’t be available.You should be able to load the custom filter when you define the
TemplateColumn. Something like:Alternative (suggested by Bradley in comments)
Instead of using
TemplateColumnin the class defining your table. Use aColumn, but define a methodrender_columnname()with the formatting. Something like:See Table.render_FOO() Methods for more detail.