Pythonanywhere "staticfiles" is not a valid tag library: no staticfiles template library found

In pythonanywhere I am 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 the error

Exception type: TemplateSyntaxError Exception:
"staticfiles" is not a valid tag library: no staticfiles template library found, tried django.templatetags.staticfiles, django.contrib.admin.templatetags.staticfiles

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

Error at index.html

{% load staticfiles %}

      

Please, help. Thanks in advance.

+3


source to share


2 answers


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



+5


source


Try:

{% load static from staticfiles %}

      

And now you can use it like this:



{% static "images/hi.jpg" as myphoto %}
<img src="{{ myphoto }}" alt="Hi!" />

      

This example is from django doc for version 1.7 /

0


source







All Articles