Django TemplateSyntaxError:找不到模板库bootstrap3

时间:2015-04-12 21:08:59

标签: django templates twitter-bootstrap-3

我是新手,我安装了django-bootstrap3。 V5.3.1 添加" bootstrap3"到我的设置文件中的INSTALLED_APPS参数, 并开始在我的模板中引用{%load bootstrap3%}。我也重新启动了django。但是,我得到错误:有谁知道我怎么解决这个问题?

TemplateSyntaxError at /jhgi/signup/

'bootstrap3' is not a valid tag library: Template library bootstrap3 not found, tried django.templatetags.bootstrap3,django.contrib.admin.templatetags.bootstrap3,django.contrib.staticfiles.templatetags.bootstrap3,django_extensions.templatetags.bootstrap3

Request Method:     GET
Request URL:    http://127.0.0.1:8000/jhgi/signup/
Django Version:     1.7.7
Exception Type:     TemplateSyntaxError
Exception Value:    

'bootstrap3' is not a valid tag library: Template library bootstrap3 not found, tried django.templatetags.bootstrap3,django.contrib.admin.templatetags.bootstrap3,django.contrib.staticfiles.templatetags.bootstrap3,django_extensions.templatetags.bootstrap3

Exception Location:     /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/template/defaulttags.py in load, line 1119
Python Executable:  /Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4
Python Version:     3.4.2
Python Path:    

['/Users/XXXX/PycharmProjects/XXXX',
 '/Applications/PyCharm.app/helpers/pydev',
 '/Users/xxxx/PycharmProjects/Companion',
 '/Library/Frameworks/Python.framework/Versions/3.4/lib/python34.zip',
 '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4',
 '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/plat-darwin',
 '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/lib-dynload',
 '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages',
 '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/IPython/extensions']

Server time:    Sun, 12 Apr 2015 20:47:32 +0000

Error during template rendering

In template /Users/xxxxx/PycharmProjects/Companion/templates/signup.html, error at line 5
'bootstrap3' is not a valid tag library: Template library bootstrap3 not found, tried django.templatetags.bootstrap3,django.contrib.admin.templatetags.bootstrap3,django.contrib.staticfiles.templatetags.bootstrap3,django_extensions.templatetags.bootstrap3

2 个答案:

答案 0 :(得分:2)

请重新检查" bootstrap3"在你的INSTALLED_APPS中并重新启动django。只有在重新启动后才会添加新的模板标签。

答案 1 :(得分:0)

在我的情况下,问题是文件系统权限。

我在CentOS 7上以普通用户身份运行,但Apache以守护程序模式运行:apache group:apache。执行pip install bootstrap3后,我忘记执行sudo chown -R :apache /srv/python,其中/srv/python/.../site-packages位于WSGIDaemonProcess中配置的python路径上。使新加载的站点包可以按组读取:apache并重新启动httpd修复了问题。