Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'bootstrap_tags' is not a valid tag library

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 %}
like image 415
Nima Avatar asked Apr 20 '14 11:04

Nima


2 Answers

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.

like image 67
Zhen Xie Avatar answered Nov 03 '22 02:11

Zhen Xie


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
like image 1
Karam Qusai Avatar answered Nov 03 '22 00:11

Karam Qusai