Django: 'current_tags' is not a valid tag library
I would suggest the following:
(Most likely) You haven't installed one of the dependencies of your tag library. Check the imports inside the
current_tags.py
module.Make sure the application that includes the tag library is registered in
settings.py
underINSTALLED_APPS
.-
Make sure that you can successfully import the tag library.
python manage.py shell >>> from app.templatetags import current_tags
This boils down what the following link recommends, which is that the error itself tends to mislead you about where it's looking for a template from. It silently ignores errors on import, which means
current_tags.py
itself might have a syntax error or another reason why it raises ImportError.
If everything else fails, check this link: http://www.b-list.org/weblog/2007/dec/04/magic-tags/
I had this problem and fixed it by adding a blank __init__.py
file in my appname/templatetags/ directory.
Possibilities are many:
- You haven't reset your dev server.
- You have dependency loop in templatetag file.
- You misspelled something (directory, folder, template name in 'load', etc.).
- You forgot about adding the app to INSTALLED_APPS.
Restart the server has solved the issue for me. They must have mentioned it in the documentation.
I was getting the same error but for a different reason so I'll tell you (in case someone else comes the same problem).
I had everything right but I had my custom tag inside a folder named template_tags
and after a long search I found out that it had to be templatetags
, and now it works. So check the folder name is exactly templatetags
.