[Django]-Django could not load template tag

6👍

With load you need to use the name of the library, not the tag – so posts in your case.

(I assume you also have a blank __init__.py in the templatetags directory, and that the application is in INSTALLED_APPS).

2👍

suppose you have the following structure:

-- Application_Name

-------templatetags

--------------__init__.py

--------------templates_extras.py

-------__init__.py

-------settings.py

-- manage.py

You have to make sure of the following:

  • your application itself inside which your “templatetags” is resident is actually installed in INSTALLED_APPS in settings.py (e.g. “Application_Name”)

  • your tag module itself that exists inside “templatetags” is already installed in INSTALLED_APP in settings.py (e.g. “ApplicationName.templatetags.tempaltes_extras”)

  • keep sure you have “__init__.py” under templatetags directory

  • you have to restart the server

  • In some cases you have to remove all generated *.pyc if it did not work then retry again

Leave a comment