How to Solve Error Message TemplateSyntaxError at / ‘staticfiles’ is not a registered tag library in Django

Posted on

This article will show how to solve the error message as it exist in the title of the article. The error message is ‘TemplateSyntaxError at / ‘staticfiles’ is not registered tag library’. The following image will show the detail of the error message :

The error above appear upon executing the command to run Django-based web application. The following are sequences of processes for executing it :

1.  Activate the python virtual environment. Execute the script activate.bat as follows :

C:\python-win>cd myenv

C:\python-win\myenv>cd Scripts


(myenv) C:\python-win\myenv\Scripts>

2. Execute the command for running the application. The folowing is the command pattern of the command :

python runserver

This is the actual execution of the command using the above command pattern :

(myenv) C:\python-win\django-project>python runserver
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).

You have 61 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, loads, sessions.
Run 'python migrate' to apply them.
May 10, 2020 - 13:33:07
Django version 3.0.5, using settings 'WAM.settings'
Starting development server at
Quit the server with CTRL-BREAK.
Internal Server Error: /
Traceback (most recent call last):
File "C:\python-win\myenv\lib\site-packages\django\template\", line 1021, in find_library
return parser.libraries[name]
KeyError: 'staticfiles'

As in the above command execution, there is an error message in the last line. It is “KeyError: ‘staticfiles’”. It means, there is an error where the cause is that one. Actually, that is quite a big hint to solve the problem. After googling for the solution, the error exist in the template file. It is because the template file has a tag for loading static files as follows :

{% load staticfiles %}

So, the solution is simple, It is because the template file has a tag for loading static files as follows :

{% load static %}

It exist in the following article with this link. It is because the application run in the Django version of 2.1. So, the other syntax for loading static files is deprecated.

Leave a Reply