【发布时间】:2018-02-26 11:42:46
【问题描述】:
我使用 django 创建了一个项目,并将其上传到 heroku。
可以在本地环境下成功运行,功能也可以正常运行。我上传成功没有任何问题,但是当我在heroku(https://APP_NAME.herokuapp.com/)中访问它时,它有一些这样的问题:
InvalidTemplateLibrary at /
Invalid template library specified. ImportError raised when trying to load 'bootstrap3.templatetags.bootstrap3': cannot import name 'flatatt'
Request Method:
GET
Request URL:
https://APP_NAME.herokuapp.com/
Django Version:
2.0.2
Exception Type:
InvalidTemplateLibrary
Exception Value:
Invalid template library specified. ImportError raised when trying to load 'bootstrap3.templatetags.bootstrap3': cannot import name 'flatatt'
Exception Location:
/app/.heroku/python/lib/python3.6/site-packages/django/template/backends/django.py in get_package_libraries, line 125
Python Executable:
/app/.heroku/python/bin/python
Python Version:
3.6.4
Python Path:
['/app',
'/app/.heroku/python/bin',
'/app',
'/app/.heroku/python/lib/python36.zip',
'/app/.heroku/python/lib/python3.6',
'/app/.heroku/python/lib/python3.6/lib-dynload',
'/app/.heroku/python/lib/python3.6/site-packages']
Server time:
Sun, 25 Feb 2018 02:19:09 +0000
我尝试使用 django-bootstrap4,但 django-bootstrap3 也有部署问题。
我该怎么办?
非常感谢。
更新:
-
requirements.txt
pip freeze > requirements.txt
requirements.txt 内容如下:
dj-database-url==0.4.2
Blockquote
django==2.0.2
-e git+https://git.heroku.com/APP_NAME.git@cbb5b522d**SECRET**710#egg=django_bootstrap3
gunicorn==19.7.1
psycopg2-binary==2.7.4
pytz==2017.3
whitenoise==3.3.1
注意:
那是原始文件。我将第4行修改为某个版本,例如django-bootstrap3==6.2.2。
- bootstrap3 设置
在我的虚拟环境中参考的一些设置:
ll_env/Lib/site-packages/bootstrap3/bootstrap.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from importlib import import_module
...
ll_env/Lib/site-packages/bootstrap3/utils.py
from django.forms.utils import flatatt
from django.template import Variable, VariableDoesNotExist
from django.template.base import FilterExpression, kwarg_re, TemplateSyntaxError
from django.template.loader import get_template
...
【问题讨论】:
-
你
requirements.txt包含什么?当您在本地环境中执行pip freeze时,这是否与输出匹配? -
感谢您的提示。我已经更新了我的问题。
-
您没有向您的问题添加任何新信息。
标签: django heroku django-bootstrap3