Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django: 'current_tags' is not a valid tag library

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 server:

TemplateSyntaxError at /

'current_tags' is not a valid tag library: Template library current_tags not found, tried django.templatetags.current_tags

The problem is with a line in an html file:

{% load current_tags %}

This exact same code works on his system with no errors. What could that be?

like image 661
snakile Avatar asked Mar 30 '11 23:03

snakile


4 Answers

I would suggest the following:

  1. (Most likely) You haven't installed one of the dependencies of your tag library. Check the imports inside the current_tags.py module.

  2. Make sure the application that includes the tag library is registered in settings.py under INSTALLED_APPS.

  3. 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/

like image 199
mif Avatar answered Nov 16 '22 23:11

mif


I had this problem and fixed it by adding a blank __init__.py file in my appname/templatetags/ directory.

like image 21
ty. Avatar answered Nov 16 '22 22:11

ty.


Possibilities are many:

  1. You haven't reset your dev server.
  2. You have dependency loop in templatetag file.
  3. You misspelled something (directory, folder, template name in 'load', etc.).
  4. You forgot about adding the app to INSTALLED_APPS.
like image 64
Ctrl-C Avatar answered Nov 17 '22 00:11

Ctrl-C


Restart the server has solved the issue for me. They must have mentioned it in the documentation.

like image 13
Krishnadas PC Avatar answered Nov 17 '22 00:11

Krishnadas PC