【问题标题】:'bootstrap_tags' is not a valid tag library“bootstrap_tags”不是有效的标签库
【发布时间】:2014-04-20 11:24:59
【问题描述】:

我将 pinax-theme-bootstrap-account 与 django-user-accounts 一起使用。

当我想使用 pinax 模板时,我收到此错误:

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

这里是 signup.html 的 pinax 主题:

{% extends "site_base.html" %}

{% load url from future %}
{% load i18n %}
{% load bootstrap_tags %}
{% block head_title %}{% trans "Sign up" %}{% endblock %}   
{% block body %}
   <div class="row">
       <div class="span8">
           <form id="signup_form" 
                  method="post" 
                  action="{% url "account_signup" %}" 
                  autocapitalize="off" 
                  class="form-horizontal"{% if form.is_multipart %}     enctype="multipart/form-data"{% endif %}>
               <legend>{% trans "Sign up" %}</legend>
               <fieldset>
                   {% csrf_token %}
                   {{ form|as_bootstrap }}
                   {% if redirect_field_value %}
                       <input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
                   {% endif %}
                   <div class="form-actions">
                       <button type="submit" class="btn btn-primary">{% trans "Sign up" %}</button>
                   </div>
               </fieldset>
           </form>
       </div>
       <div class="span4">
           {% include "account/_signup_sidebar.html" %}
       </div>
   </div> {% endblock %}

【问题讨论】:

    标签: django twitter-bootstrap pinax


    【解决方案1】:

    这个错误是因为没有安装django_forms_bootstrap Python包;因此, django.forms.bootstrap 导入失败。

    pip install django_forms_bootstrap
    

    然后将'django_forms_bootstrap'添加到settings.py中的INSTALLED_APPS

    然后重新启动您的网站或运行服务器。

    【讨论】:

      【解决方案2】:

      更新...

      如果你升级到bootstrap4,你会遇到这个错误:

      'bootstrap4' 不是注册的标签库。

      为Bootstrap4解决:官网link

      或者使用 Python 中的简易安装功能:

      pip install django-bootstrap4
      

      【讨论】:

        猜你喜欢
        • 2015-09-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-11-11
        • 2011-05-31
        • 1970-01-01
        • 2012-08-22
        • 2012-04-02
        相关资源
        最近更新 更多