I have a small Django project I received from a friend. The code works perfectly on his system. However, on my system I get the following error message when running the serv
In my case I have created library instance using tag variable instead of register variable
tag = template.Library()
But it should be
register = template.Library()
To be a valid tag library, the module must contain a module-level variable named register that is a template.Library instance, in which all the tags and filters are registered
After you have created the template tag and it should be within the 'templatetags' package within an app installed in the settings.INSTALLED_APPS, make sure you restart your dev-server.
All of the advice listed here didn't help me. So in my specific case the problem was that the templatetag had to be loaded from a third-party app, and I manually copied source folder with that app into src
folder in my virtualenv. Then I ran python setup.py install
inside that folder. After that django could not load this module.
Then I removed the source and installed folder of this app and installed it using pip install -r requirements.txt
after adding a relevant line into requirements.txt
file. It was downloaded into the src
folder, installed and everything began working properly. Hope this helps someone.
I had this problem and fixed it by adding a blank __init__.py
file in my appname/templatetags/ directory.
Possibilities are many: