'bootstrap_tags' is not a valid tag library
Asked Answered
Q

4

7

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 %}
Quire answered 20/4, 2014 at 11:24 Comment(0)
I
11

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.

Injury answered 22/4, 2014 at 20:44 Comment(0)
B
5

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
Belgium answered 12/8, 2019 at 7:40 Comment(0)
G
3

Another update for django-bootstrap5.

I spent quite some time with this error. There are two tricky parts about the fifth version.

For starters beware of what you add. There are two concurrent packages on PYPI that have very similar names. One is django-bootstrap5 and the other is django-bootstrap-v5. The one you want is the former; django-bootstrap5.

Secondly you are likely to mess up the import, since it has to be different from django-bootstrap5 (since python does not support - in package names). The correct import is simply django_bootstrap5. This seems obvious but a lot of tutorials online (including the one I followed) refer to imports like this bootstrap5, that might be legacy or something but it doesn't work.

In summary

pip install django-bootstrap5

Install the correct package.

{% load django_bootstrap5 %}

In your base.html equivalent include the package like so.

INSTALLED_APPS = [

 ...
    'django_bootstrap5',
 ...

]

In the settings.py of your project add the package to INSTALLED_APPS.

I hope this helps someone down the line!

Goethite answered 17/1 at 14:1 Comment(0)
H
-1

django-bootstrap4 installation solved it

Hedgehog answered 10/5, 2022 at 15:24 Comment(1)
This answer is just a duplicate with less information.Given

© 2022 - 2024 — McMap. All rights reserved.