I'm having this error when loading a custom tag in my template. I've visited many topics about this and I made sure to verify that I didn't commit some common errors :
- The file containing the tags is in the
templatetagsfolder. - This
templatetagsfolder contains a__init__.pyfile. - The app
actualitesis in theINSTALLED_APPSlist from the settings. - I'm using
{% load mes_tags %}at the beginning of my template.
Here is the file structure of my app :
actualites/
__init__.py
SOME FILES
templatetags/
__init__.py
mes_tags.py
mes_tags.py
from django import template
register = template.Library()
@register.simple_tag(takes_context=True)
def param_replace(context, **kwargs):
d = context['request'].GET.copy()
for k, v in kwargs.items():
d[k] = v
for k in [k for k, v in d.items() if not v]:
del d[k]
return d.urlencode()
The error I get is the following :
TemplateSyntaxError at /
'mes_tags' is not a registered tag library. Must be one of:
LIST OF TAGS
Can someone tell me what I did wrong ? Thanks in advance !
You need to add this tags library in settings (for Django >= 1.9):
You can read more here