【问题标题】:'bootstrap3' is not a valid tag library: ImportError raised loading bootstrap3.templatetags.bootstrap3: cannot import name force_text“bootstrap3”不是有效的标签库:ImportError raise loading loading bootstrap3.templatetags.bootstrap3: cannot import name force_text
【发布时间】:2014-03-03 10:56:28
【问题描述】:

我正在通过这个链接浏览关于 django-bootstrap 的教程:“https://pypi.python.org/pypi/django-bootstrap3https://pypi.python.org/pypi/django-bootstrap3

在我的 settings.py 中:

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'myapp',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
'example_app',
'southtut',
'south',
'bootstrap3',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',

)

在我的模板中:

我写了

 {% load bootstrap3 %}

但我在模板中的上述行中得到以下内容,例如:

TemplateSyntaxError at /myapp/product/
'bootstrap3' is not a valid tag library: ImportError raised loading     bootstrap3.templatetags.bootstrap3: cannot import name force_text
Request Method: GET
Request URL:    http://127.0.0.1:8000/myapp/product/
Django Version: 1.4.1
Exception Type: TemplateSyntaxError
Exception Value:    
'bootstrap3' is not a valid tag library: ImportError raised loading      bootstrap3.templatetags.bootstrap3: cannot import name force_text
Exception Location: C:\Python27\lib\site-packages\django\template\defaulttags.py in  load, line 1043
Python Executable:  C:\Python27\python.exe
Python Version: 2.7.1
Python Path:    
['C:\\Users\\Gopi\\workspace\\myfirst',
'C:\\Python27\\lib\\site-packages\\geraldo-0.4.16-py2.7.egg',
'C:\\Python27\\lib\\site-packages\\configparser-3.2.0r3-py2.7.egg',
'C:\\Python27\\lib\\site-packages\\unittest2-0.5.1-py2.7.egg',
'C:\\Python27\\lib\\site-packages\\ordereddict-1.1-py2.7.egg',
'C:\\Python27\\lib\\site-packages\\passlib-1.6.1-py2.7.egg',
'C:\\Python27\\lib\\site-packages\\south-0.8.3-py2.7.egg',
 'C:\\Python27\\lib\\site-packages\\openpyxl-1.7.0-py2.7.egg',
'C:\\Python27\\lib\\site-packages\\xlutils-1.7.0-py2.7.egg',
 'C:\\Python27\\lib\\site-packages\\tesseracttrainer-0.1.1-py2.7.egg',
 'C:\\Python27\\lib\\site-packages\\goslate-1.1.2-py2.7.egg',
 'C:\\Python27\\lib\\site-packages\\futures-2.1.6-py2.7.egg',
 'C:\\Windows\\system32\\python27.zip',
'C:\\Python27\\DLLs',
'C:\\Python27\\lib',
'C:\\Python27\\lib\\plat-win',
'C:\\Python27\\lib\\lib-tk',
'C:\\Python27',
'C:\\Python27\\lib\\site-packages',
'C:\\Python27\\lib\\site-packages\\PIL',
'C:\\Python27\\lib\\site-packages\\win32',
'C:\\Python27\\lib\\site-packages\\win32\\lib',
'C:\\Python27\\lib\\site-packages\\Pythonwin',
'C:\\Python27\\lib\\site-packages\\wx-2.8-msw-unicode']
Server time:    Mon, 3 Mar 2014 16:18:18 +0530

我不知道我错在哪里。请帮帮我

【问题讨论】:

    标签: django twitter-bootstrap python-2.7 django-1.4


    【解决方案1】:

    这里的错误是“无法导入名称 force_text”,这是因为您使用的是 Django 1.4

    【讨论】:

    • 但在说明中说 django >= 1.4
    • 我在网站要求 Python 2.6、2.7 和 3.3 Django >= 1.4 中找到了这个
    • 我已修复并将其发布给 django-bootstrap3 创建者,它现在应该可以为您工作了。
    • 只需运行:pip install django-bootstrap3 --upgrade
    • 如何解决这个问题,有人帮帮我
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-20
    • 2016-05-16
    • 2018-10-27
    • 2020-07-16
    • 2019-06-10
    • 2014-09-25
    相关资源
    最近更新 更多