'bootstrap_tags' is not a valid tag library

ε祈祈猫儿з 提交于 2019-12-07 07:51:18

问题


I'm using pinax-theme-bootstrap-account with django-user-accounts.

When I want to use pinax templates I get this error:

'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

Here is pinax-theme for signup.html:

{% 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 %}

回答1:


This error is due to the django_forms_bootstrap Python package not being installed; therefore, the django.forms.bootstrap import is failing.

pip install django_forms_bootstrap

Then add 'django_forms_bootstrap' to INSTALLED_APPS in settings.py

and then restart your website or runserver.




回答2:


An update...

if you upgrade it to bootstrap4, you will face this error:

'bootstrap4' is not a registered tag library.

To solve it for Bootstrap4: official website link

Or use the easy installation feature in Python:

pip install django-bootstrap4


来源:https://stackoverflow.com/questions/23181448/bootstrap-tags-is-not-a-valid-tag-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!