So I was just working on a project and wanted to create my own template filter to help me do stuffs. And I looked at Django's documentation, on how to create a custom template filters. I followed all the instructions but too bad it didn't work :( and gave me the TemplateSyntaxError at my_app/ and also with Invalid Filter: 'my_filter'

Then I looked on the internet and read some answers from stack overflow but still couldn't get things to work. In the end, I found a fix to the problem.

In addition to create a templatetags directory inside my app, I also need to update the TEMPLATES inside the project's So now, I will hopefully add all the steps needed to create your own template filter.

First, you need to create the templatetags directory inside my_app. So the structure will look something like this

|- templatetags

And then you put your custom filter inside

from django import template
register = template.Library()

def my_filter(ob):

And also update

'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'builtins': [

Also, don't forget to load it inside template.html

{% load app_filters %}

I hope this will help people who had this problem. Have a nice day :)