{"id":3913,"library":"bootstrap-flask","title":"Bootstrap-Flask","description":"Bootstrap-Flask is a collection of Jinja macros for Bootstrap 4 & 5 and Flask. It helps to render Flask-related data and objects to Bootstrap markup HTML more easily, such as Flask-WTF forms, data tables, and pagination. The library is actively maintained, with a recent release of 2.5.0, and typically sees updates to align with new Bootstrap versions and address Python compatibility.","status":"active","version":"2.5.0","language":"en","source_language":"en","source_url":"https://github.com/helloflask/bootstrap-flask","tags":["Flask","Bootstrap","Web Development","Jinja2","Forms","Frontend"],"install":[{"cmd":"pip install bootstrap-flask","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Core web framework integration.","package":"Flask","optional":false},{"reason":"Commonly used for form rendering capabilities.","package":"Flask-WTF","optional":true},{"reason":"Forms generation and validation, often used via Flask-WTF.","package":"WTForms","optional":true}],"imports":[{"note":"Use this class to initialize Bootstrap 5 support in your Flask application.","symbol":"Bootstrap5","correct":"from flask_bootstrap import Bootstrap5"},{"note":"Use this class to initialize Bootstrap 4 support in your Flask application.","symbol":"Bootstrap4","correct":"from flask_bootstrap import Bootstrap4"},{"note":"The generic `Bootstrap` class is deprecated since version 2.0.0 and will be removed in 3.0. You should explicitly use `Bootstrap4` or `Bootstrap5` instead.","wrong":"from flask_bootstrap import Bootstrap","symbol":"Bootstrap","correct":"N/A"}],"quickstart":{"code":"from flask import Flask, render_template\nfrom flask_bootstrap import Bootstrap5\nfrom flask_wtf import FlaskForm\nfrom wtforms import StringField, PasswordField, BooleanField, SubmitField\nfrom wtforms.validators import DataRequired, Length\nimport os\n\napp = Flask(__name__)\napp.config['SECRET_KEY'] = os.environ.get('SECRET_KEY', 'a_default_secret_key_for_dev')\nbootstrap = Bootstrap5(app)\n\nclass LoginForm(FlaskForm):\n    username = StringField('Username', validators=[DataRequired(), Length(1, 20)])\n    password = PasswordField('Password', validators=[DataRequired(), Length(8, 150)])\n    remember = BooleanField('Remember me')\n    submit = SubmitField('Log In')\n\n@app.route('/', methods=['GET', 'POST'])\ndef index():\n    form = LoginForm()\n    if form.validate_on_submit():\n        # In a real application, process the form data (e.g., login user)\n        return f\"Login successful for {form.username.data}! Remember me: {form.remember.data}\"\n    return render_template('index.html', form=form)\n\n# To run this, save it as app.py and create a 'templates' folder.\n# Inside 'templates', create 'index.html' with the following content:\n#\n# <!doctype html>\n# <html lang=\"en\">\n# <head>\n#     <meta charset=\"utf-8\">\n#     <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\">\n#     <title>Login</title>\n#     {{ bootstrap.load_css() }}\n# </head>\n# <body>\n#     <div class=\"container\">\n#         <h2 class=\"mt-3\">Login</h2>\n#         {% from 'bootstrap5/form.html' import render_form %}\n#         {{ render_form(form) }}\n#     </div>\n#     {{ bootstrap.load_js() }}\n# </body>\n# </html>\n#\n# Then install dependencies:\n# pip install flask bootstrap-flask flask-wtf\n# And run:\n# export SECRET_KEY='your_strong_secret_key' # or set on Windows/Powershell\n# flask run","lang":"python","description":"This quickstart demonstrates how to set up a basic Flask application, initialize Bootstrap-Flask for Bootstrap 5, define a simple Flask-WTF form, and render it using Bootstrap-Flask's `render_form` macro in a Jinja2 template. It also shows how to include Bootstrap's CSS and JS resources using the helper functions."},"warnings":[{"fix":"Run `pip uninstall flask-bootstrap` then `pip install bootstrap-flask`. Update template paths from `bootstrap/` to `bootstrap4/` or `bootstrap5/`.","message":"Migration from the older `Flask-Bootstrap` library to `Bootstrap-Flask` requires full uninstallation of `Flask-Bootstrap` before installing `bootstrap-flask`. They cannot coexist in the same environment and use different template paths.","severity":"breaking","affected_versions":"All versions when migrating from `Flask-Bootstrap`"},{"fix":"Replace `Bootstrap(app)` with `Bootstrap4(app)` or `Bootstrap5(app)`. Update Jinja2 template imports from `{% from 'bootstrap/...' %}` to `{% from 'bootstrap4/...' %}` or `{% from 'bootstrap5/...' %}`.","message":"Since version 2.0.0, the generic `Bootstrap` class and the `bootstrap/` template path are deprecated. Users must now explicitly choose and initialize `Bootstrap4` for Bootstrap 4 or `Bootstrap5` for Bootstrap 5.","severity":"breaking","affected_versions":"2.0.0+"},{"fix":"Upgrade your Python environment to 3.9 or newer.","message":"Python 3.6 support was dropped in version 2.2.0.","severity":"deprecated","affected_versions":"2.2.0+"},{"fix":"Upgrade your Python environment to 3.9 or newer.","message":"Python 3.7 and 3.8 support was dropped in version 2.5.0.","severity":"deprecated","affected_versions":"2.5.0+"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}