Search code examples
pythondjangodjango-staticfilespythonanywhere

Pythonanywhere 'staticfiles' is not a valid tag library: Template library staticfiles not found


In pythonanywhere, I'm using virtualenv with Django 1.7 and Python 2.7

Settings.py

STATIC_ROOT = '/home/movies/pantherlist/movies/static/'
STATIC_URL = '/static/'

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'pantherlist.movies',
)

wsgi.py

activate_this = '/home/movies/.virtualenvs/django17/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
.
.#path setup already done here
.
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

I am getting error

Exception Type: TemplateSyntaxError Exception Value:
'staticfiles' is not a valid tag library: Template library staticfiles not found, tried django.templatetags.staticfiles,django.contrib.admin.templatetags.staticfiles

Exception Location: /usr/local/lib/python2.7/dist-packages/django/template/defaulttags.py in load, line 1054

Error at index.html

{% load staticfiles %}

Please help. Thanks in advance.


Solution

  • It looks like you haven't reloaded your web app since adding the virtualenv activation to your wsgi file, or you're not using the wsgi file that you think you're using. The error location that Django is reporting (/usr/local/lib/python2.7/dist-packages/django/template/defaulttags.py) is in the default system Django on PythonAnywhere , not the Django in your virtualenv.