1

I have the flask-bootstrap already installed and imported into my project through a virtualenv. I am trying to initiate the 'base.html' template that comes with the flask-bootstrap package but when I load my project, the website doesn't display any sign of bootstrap. How do I solve this? Below is how I imported the flask_bootstrap package.

from flask import Flask, render_template
from flask_script import Manager
from flask_bootstrap import Bootstrap

app = Flask(__name__)
manager = Manager(app)
bootstrap = Bootstrap(app)


@app.route('/index')
def index():
    return render_template('index.html')

@app.route('/user/<name>')
def user(name):
    return render_template('user.html', name=name)


if __name__ == '__main__':
    manager.run()

Also, this is the code I am trying to initiate the package from:

{% extends "bootstrap/base.html" %}
{% block title %}Flasky{% endblock %}

{% block navbar %}
<div class="navbar navbar-inverse" role="navigation">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="/">Flasky</a>
        </div>
        <div class="navbar-collapse collapse">
            <ul class="nav navbar-nav">
                <li><a href="/">Home</a></li>
            </ul>
        </div>
    </div>
</div>
{% endblock %}

{% block content %}
<div class="container">
    <div class="page-header">
        <h1>Hello, {{ name }}!</h1>
    </div>
</div>
{% endblock %}

But this is the result I get:

flasky-sample

Evans I.
  • 11
  • 4
  • You only have a Navbar and it sure looks like it has some bootstrap default styling on it (the page header class even positions the text properly). What else were you expecting to see? – danidee Jan 03 '17 at 14:44
  • Agree with @danidee here. This appears to be expected output, for the most part (albeit I thought "navbar-inverse" was black), but you've got `li` items rendering as a menu bar...that counts as bootstrap. Expand the example a bit and you should be able to get better style, use the [Bootstrap example](http://getbootstrap.com/components/#navbar). Also--this may be fine, but every example I've ever seen for `data-target` for your first `button` element is usually an ID, not a class. – abigperson Jan 03 '17 at 15:45
  • @danidee I'm expecting to see an inverse navbar and the "Hello Evans!" is expected to be below the navbar – Evans I. Jan 03 '17 at 18:55
  • @PJSantoro Yea! I was expecting a black navbar... Also with the proper glyphicon – Evans I. Jan 03 '17 at 18:57

0 Answers0