Django 1.10.1 'my_templatetag' is not a registered tag library. Must be one of: Django 1.10.1 'my_templatetag' is not a registered tag library. Must be one of: django django

Django 1.10.1 'my_templatetag' is not a registered tag library. Must be one of:


Besides putting my_templatetag.py inside app_name/templatetags, make sure you restart the Django development server (or ensure it restarted itself) every time you modify template tags. If the server does not restart, Django won't register the tags.


From Django 1.9, you can load those new tags/filters in settings like this:

TEMPLATES = [{    'BACKEND': 'django.template.backends.django.DjangoTemplates',    'DIRS': [],    'APP_DIRS': True,    'OPTIONS': {        'context_processors': [            'django.template.context_processors.debug',            'django.template.context_processors.request',            'django.contrib.auth.context_processors.auth',            'django.contrib.messages.context_processors.messages',            'app.apptemplates.load_setting',                    ],                        'libraries':{            'my_templatetag': 'app.templatetags.my_templatetag',                        }    },},

]

If you have templatetag dir in your project dir (not in an app dir), then above method is recommended.

Example-
enter image description here

Quoting:https://docs.djangoproject.com/en/3.2/howto/custom-template-tags/#:~:text=It%20also%20enables%20you%20to%20register%20tags%20without%20installing%20an%20application.


Make sure you are not missing any of the following steps:

  1. Create a folder called "templatetags" at the same level as models.pyand views.py in your application folder

  2. Your application must be in the INSTALLED_APPS in settings.py

  3. The templatetags folder must have __init__.py

  4. Restart the django server