[英]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 在pythonanywhere中,我正在使用带有Django 1.7和Python 2.7的virtualenv
Settings.py 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 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: 异常类型:TemplateSyntaxError异常值:
'staticfiles' is not a valid tag library: Template library staticfiles not found, tried django.templatetags.staticfiles,django.contrib.admin.templatetags.staticfiles 'staticfiles'不是有效的标记库:找不到模板库staticfiles,尝试过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 异常位置:/usr/local/lib/python2.7/dist-packages/django/template/defaulttags.py in load,1054行
Error at index.html index.html出错
{% load staticfiles %}
Please help. 请帮忙。 Thanks in advance.
提前致谢。
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. 看起来您没有重新加载您的Web应用程序,因为将virtualenv激活添加到您的wsgi文件,或者您没有使用您认为正在使用的wsgi文件。 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.
Django报告的错误位置(/usr/local/lib/python2.7/dist-packages/django/template/defaulttags.py)位于PythonAnywhere上的默认系统Django中,而不是virtualenv中的Django。
Try: 尝试:
{% load static from staticfiles %}
And now you can use it in this way: 现在你可以这样使用它:
{% static "images/hi.jpg" as myphoto %}
<img src="{{ myphoto }}" alt="Hi!" />
This example is from django doc for 1.7 version/ 这个例子来自django doc for 1.7 version /
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.