简体   繁体   English

Pythonanywhere'staticfiles'不是有效的标记库:找不到模板库staticfiles

[英]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.

相关问题 Django TemplateSyntaxError - 'staticfiles' 不是注册的标签库 - Django TemplateSyntaxError - 'staticfiles' is not a registered tag library PyCharm - 未解决的库“staticfiles” - PyCharm - Unresolved library 'staticfiles' &#39;staticfiles&#39; 不是注册标签库:这些解决方案不起作用 - 'staticfiles' is not a registered tag library: These solutions don't work 静态文件不是注册标签,静态文件未加载 - Staticfiles not a registered tag and staticfiles not loading django_rest_swagger - &#39;staticfiles&#39; 不是注册的标签库。 必须是以下之一: - django_rest_swagger - 'staticfiles' is not a registered tag library. Must be one of: /en/admin/login/ 'staticfiles' 处的 TemplateSyntaxError 不是已注册的标签库。 必须是以下之一: - TemplateSyntaxError at /en/admin/login/ 'staticfiles' is not a registered tag library. Must be one of: /&#39;staticfiles&#39; 处的 Django TemplateSyntaxError 不是已注册的标记库。 必须是以下之一:admin_list admin_modify admin_urls - Django TemplateSyntaxError at / 'staticfiles' is not a registered tag library. Must be one of: admin_list admin_modify admin_urls 在 django 1.9 中找不到我的静态文件 - Not found my staticfiles in django 1.9 在 Heroku 上找不到 Django 静态文件(带白噪声) - Django staticfiles not found on Heroku (with whitenoise) 为什么要为每个模板加载静态文件,即使它已被扩展? - Why load staticfiles for every template even if it is extended?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM