1

I am creating a couple pages for my website by extending a base.html template that I made. I want to be able to put bootstrap forms on some of the pages, but when I have the {% bootstrap_form formname %} tag inside the {% block content %} tag I get an error: Invalid block tag: 'bootstrap_form', expected 'endblock'.

Does anyone know how to put bootstrap tags inside of a template block??

My base.html:

<html>

<head>
  <title>{% block title %}CYGNSS SIMPL{% endblock %}</title>
</head>
<body>
  {% block content %}{% endblock %}
  <div class="container">
    <img class="img-responsive center-block" src="{% static "images/logo.png" %}" alt="Picture"/>
  </div>
  {% block footer %}{% endblock %}
</body>
</html>

My template:

{% extends "InterfaceApp/base.html" %}

{% block title %}Request Generator{% endblock %}

{% block content %}
<div class="container">
  <div class="page-header">
    <h1>
      <p class="text-center">Such Request Generator</p>
    </h1>
  </div>
  <div class="container-fluid">
    <div class="panel panel-default">
      <div class="panel-heading">
        <p class="text-center">
          Generate a Request. 
        </p>
      </div>
      <div class="container-fluid">
        <form action="/InterfaceApp/Manual_Request/" method="post" class="form" onsubmit="return checkForm( this )">
          {% csrf_token %}
          <div class="panel-body text-center">
            <table class="table-responsive centering">
              <tbody>
                <tr>
                  <td>
                    {% bootstrap_form form_length %}
                  </td>
                </tr>
              </tbody>
            </table>
            <br>
            <table class="table-responsive centering">
              <tbody>
                <tr>
                  {% buttons %}
                  <td>
                    <button type="submit" class="btn btn-primary center-block" value="Submit">
                      {% bootstrap_icon "fire" %} Generate Manual Request
                    </button>
                  </td>
                  {% endbuttons %}
                </tr>
              </tbody>
            </table>
          </div>
        </form>
      </div>
    </div>
  </div>
</div>
{% endblock %}

Any help is much appreciated!

2
  • I don't see how is this error has anything to do with bootstrap. Commented Jul 15, 2015 at 16:38
  • 1
    try adding {% load bootstrap %} at the top of your page or which ever bootstrap application you have installed/ Commented Jul 15, 2015 at 16:54

1 Answer 1

0

@AjayGupta answer worked for me. I did pip install django-bootstrap-toolkit, added 'bootstrap-toolkit to my INSTALLED_APS and then included {% load bootstrap_toolkit %} at the tope of my templates.

Sign up to request clarification or add additional context in comments.

1 Comment

pleasure I was of any help . :D

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.