[Answered ]-"TemplateSyntaxError: Invalid filter:"; custom django template filter based on django docs broken, but template tags working

2👍

✅

You need to make sure you import the file with register.filter('shorten_title', shorten_title) before you render the template. Since that call happens outside of any functions it is run when you import the module. This has the side effect of registering it so that it will be available in your templates afterwards.

Leave a comment