Bootstrap-Flask


NameBootstrap-Flask JSON
Version 2.4.0 PyPI version JSON
download
home_pageNone
SummaryBootstrap 4 & 5 helper for your Flask projects.
upload_time2024-04-07 13:19:58
maintainerNone
docs_urlNone
authorNone
requires_pythonNone
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Bootstrap-Flask

![PyPI - License](https://img.shields.io/pypi/l/bootstrap-flask)
[![Current version on PyPI](https://img.shields.io/pypi/v/bootstrap-flask)](https://pypi.org/project/bootstrap-flask/)
[![Build status](https://github.com/helloflask/bootstrap-flask/workflows/build/badge.svg)](https://github.com/helloflask/bootstrap-flask/actions)
[![Coverage Status](https://coveralls.io/repos/github/helloflask/bootstrap-flask/badge.svg?branch=master)](https://coveralls.io/github/helloflask/bootstrap-flask?branch=master)
[![Open Collective](https://img.shields.io/opencollective/all/bootstrap-flask)](https://opencollective.com/bootstrap-flask)

Bootstrap-Flask is a collection of Jinja macros for Bootstrap 4 & 5 and Flask. It helps you to
render Flask-related data and objects to Bootstrap markup HTML more easily:

- Render Flask-WTF/WTForms form object to Bootstrap Form.
- Render data objects (dict or class objects) to Bootstrap Table.
- Render Flask-SQLAlchemy `Pagination` object to Bootstrap Pagination.
- etc.


## Installation

```
$ pip install -U bootstrap-flask
```

## Example

Register the extension:

```python
from flask import Flask
# To follow the naming rule of Flask extension, although
# this project's name is Bootstrap-Flask, the actual package
# installed is named `flask_bootstrap`.
from flask_bootstrap import Bootstrap5

app = Flask(__name__)
bootstrap = Bootstrap5(app)
```

Assuming you have a Flask-WTF form like this:

```python
class LoginForm(FlaskForm):
    username = StringField('Username', validators=[DataRequired(), Length(1, 20)])
    password = PasswordField('Password', validators=[DataRequired(), Length(8, 150)])
    remember = BooleanField('Remember me')
    submit = SubmitField()
```

Now with the `render_form` macro:

```html
{% from 'bootstrap5/form.html' import render_form %}
<html>
<head>
<!-- Bootstrap CSS -->
</head>
<body>

<h2>Login</h2>
{{ render_form(form) }}

<!-- Bootstrap JS -->
</body>
</html>
```

You will get a form like this with only one line code (i.e. `{{ render_form(form) }}`):

![form rendering](./docs/_static/form-example.png)

When the validation fails, the error messages will be rendered with proper style:

![error form rendering](./docs/_static/error-form-example.png)

Read the [Basic Usage](https://bootstrap-flask.readthedocs.io/en/stable/basic) 
docs for more details.


## Live demo

https://bootstrap-flask-example.azurewebsites.net/


## Donate

If you find Bootstrap-Flask useful, please consider
[donating today](https://opencollective.com/bootstrap-flask/donate). Your donation keeps
Bootstrap-Flask maintained and updated with Bootstrap.


## Links

- [Documentation](https://bootstrap-flask.readthedocs.io)
- [Example Application](https://github.com/helloflask/bootstrap-flask/tree/master/examples)
- [PyPI Releases](https://pypi.org/project/Bootstrap-Flask/)
- [Changelog](https://github.com/helloflask/bootstrap-flask/blob/master/CHANGES.rst)
- [Discussions](https://github.com/helloflask/bootstrap-flask/discussions)


## Notes for Bootstrap 4 & 5 support

The Bootstrap 5 support is added in Bootstrap-Flask 2.0 version. Now you can use
the separate extension class for different Bootstrap major versions.

For Bootstrap 4, use the `Bootstrap4` class:

```python
from flask_bootstrap import Bootstrap4

# ...
bootstrap = Bootstrap4(app)
```

and import macros from the template path `bootstrap4/`:

```html
{% from 'bootstrap4/form.html' import render_form %}
```

For Bootstrap 5, use the `Bootstrap5` class:

```python
from flask_bootstrap import Bootstrap5

# ...
bootstrap = Bootstrap5(app)
```

and import macros from the template path `bootstrap5/`:

```html
{% from 'bootstrap5/form.html' import render_form %}
```

The `Bootstrap` class and `bootstrap/` template path are deprecated since 2.0
and will be removed in 3.0.


## Migration from Flask-Bootstrap

If you come from Flask-Bootstrap, check out
[this tutorial](https://bootstrap-flask.readthedocs.io/en/stable/migrate/) on how to
migrate to this extension.


## Contributing

For guidance on setting up a development environment and how to make a
contribution to Bootstrap-Flask, see the
[development documentation](https://bootstrap-flask.readthedocs.io/en/stable/#development)
and Flask's
[contributing guidelines](https://github.com/pallets/flask/blob/main/CONTRIBUTING.rst).


## License

This project is licensed under the MIT License (see the `LICENSE` file for
details). Some macros were part of Flask-Bootstrap and were modified under
the terms of its BSD License.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "Bootstrap-Flask",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "Grey Li <withlihui@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/7a/af/6db8af36a760e5d00a0f21c147b4ae754d77e25685b7d23464e333746809/Bootstrap-Flask-2.4.0.tar.gz",
    "platform": null,
    "description": "# Bootstrap-Flask\n\n![PyPI - License](https://img.shields.io/pypi/l/bootstrap-flask)\n[![Current version on PyPI](https://img.shields.io/pypi/v/bootstrap-flask)](https://pypi.org/project/bootstrap-flask/)\n[![Build status](https://github.com/helloflask/bootstrap-flask/workflows/build/badge.svg)](https://github.com/helloflask/bootstrap-flask/actions)\n[![Coverage Status](https://coveralls.io/repos/github/helloflask/bootstrap-flask/badge.svg?branch=master)](https://coveralls.io/github/helloflask/bootstrap-flask?branch=master)\n[![Open Collective](https://img.shields.io/opencollective/all/bootstrap-flask)](https://opencollective.com/bootstrap-flask)\n\nBootstrap-Flask is a collection of Jinja macros for Bootstrap 4 & 5 and Flask. It helps you to\nrender Flask-related data and objects to Bootstrap markup HTML more easily:\n\n- Render Flask-WTF/WTForms form object to Bootstrap Form.\n- Render data objects (dict or class objects) to Bootstrap Table.\n- Render Flask-SQLAlchemy `Pagination` object to Bootstrap Pagination.\n- etc.\n\n\n## Installation\n\n```\n$ pip install -U bootstrap-flask\n```\n\n## Example\n\nRegister the extension:\n\n```python\nfrom flask import Flask\n# To follow the naming rule of Flask extension, although\n# this project's name is Bootstrap-Flask, the actual package\n# installed is named `flask_bootstrap`.\nfrom flask_bootstrap import Bootstrap5\n\napp = Flask(__name__)\nbootstrap = Bootstrap5(app)\n```\n\nAssuming you have a Flask-WTF form like this:\n\n```python\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()\n```\n\nNow with the `render_form` macro:\n\n```html\n{% from 'bootstrap5/form.html' import render_form %}\n<html>\n<head>\n<!-- Bootstrap CSS -->\n</head>\n<body>\n\n<h2>Login</h2>\n{{ render_form(form) }}\n\n<!-- Bootstrap JS -->\n</body>\n</html>\n```\n\nYou will get a form like this with only one line code (i.e. `{{ render_form(form) }}`):\n\n![form rendering](./docs/_static/form-example.png)\n\nWhen the validation fails, the error messages will be rendered with proper style:\n\n![error form rendering](./docs/_static/error-form-example.png)\n\nRead the [Basic Usage](https://bootstrap-flask.readthedocs.io/en/stable/basic) \ndocs for more details.\n\n\n## Live demo\n\nhttps://bootstrap-flask-example.azurewebsites.net/\n\n\n## Donate\n\nIf you find Bootstrap-Flask useful, please consider\n[donating today](https://opencollective.com/bootstrap-flask/donate). Your donation keeps\nBootstrap-Flask maintained and updated with Bootstrap.\n\n\n## Links\n\n- [Documentation](https://bootstrap-flask.readthedocs.io)\n- [Example Application](https://github.com/helloflask/bootstrap-flask/tree/master/examples)\n- [PyPI Releases](https://pypi.org/project/Bootstrap-Flask/)\n- [Changelog](https://github.com/helloflask/bootstrap-flask/blob/master/CHANGES.rst)\n- [Discussions](https://github.com/helloflask/bootstrap-flask/discussions)\n\n\n## Notes for Bootstrap 4 & 5 support\n\nThe Bootstrap 5 support is added in Bootstrap-Flask 2.0 version. Now you can use\nthe separate extension class for different Bootstrap major versions.\n\nFor Bootstrap 4, use the `Bootstrap4` class:\n\n```python\nfrom flask_bootstrap import Bootstrap4\n\n# ...\nbootstrap = Bootstrap4(app)\n```\n\nand import macros from the template path `bootstrap4/`:\n\n```html\n{% from 'bootstrap4/form.html' import render_form %}\n```\n\nFor Bootstrap 5, use the `Bootstrap5` class:\n\n```python\nfrom flask_bootstrap import Bootstrap5\n\n# ...\nbootstrap = Bootstrap5(app)\n```\n\nand import macros from the template path `bootstrap5/`:\n\n```html\n{% from 'bootstrap5/form.html' import render_form %}\n```\n\nThe `Bootstrap` class and `bootstrap/` template path are deprecated since 2.0\nand will be removed in 3.0.\n\n\n## Migration from Flask-Bootstrap\n\nIf you come from Flask-Bootstrap, check out\n[this tutorial](https://bootstrap-flask.readthedocs.io/en/stable/migrate/) on how to\nmigrate to this extension.\n\n\n## Contributing\n\nFor guidance on setting up a development environment and how to make a\ncontribution to Bootstrap-Flask, see the\n[development documentation](https://bootstrap-flask.readthedocs.io/en/stable/#development)\nand Flask's\n[contributing guidelines](https://github.com/pallets/flask/blob/main/CONTRIBUTING.rst).\n\n\n## License\n\nThis project is licensed under the MIT License (see the `LICENSE` file for\ndetails). Some macros were part of Flask-Bootstrap and were modified under\nthe terms of its BSD License.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Bootstrap 4 & 5 helper for your Flask projects.",
    "version": "2.4.0",
    "project_urls": {
        "Changes": "https://bootstrap-flask.readthedocs.io/en/stable/changelog/",
        "Discussions": "https://github.com/helloflask/bootstrap-flask/discussions/",
        "Documentation": "https://bootstrap-flask.readthedocs.io/en/stable/",
        "Funding": "https://opencollective.com/bootstrap-flask",
        "Issue Tracker": "https://github.com/helloflask/bootstrap-flask/issues/",
        "Source Code": "https://github.com/helloflask/bootstrap-flask/"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "27892fd8fe958d37cf97969d1b1fc4c4e39b798704e79522c5d3c51bce9a5581",
                "md5": "a107568b1e107790a65456278f0db593",
                "sha256": "bd5084bcb1557e85db799aa9d70b153cb13a3895ea871603dbf242cd05894b90"
            },
            "downloads": -1,
            "filename": "Bootstrap_Flask-2.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a107568b1e107790a65456278f0db593",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 3943766,
            "upload_time": "2024-04-07T13:19:55",
            "upload_time_iso_8601": "2024-04-07T13:19:55.183887Z",
            "url": "https://files.pythonhosted.org/packages/27/89/2fd8fe958d37cf97969d1b1fc4c4e39b798704e79522c5d3c51bce9a5581/Bootstrap_Flask-2.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7aaf6db8af36a760e5d00a0f21c147b4ae754d77e25685b7d23464e333746809",
                "md5": "812bf54d86e47136f30f8aa2834ff466",
                "sha256": "3f7aa1b8be31e182fa2eaff2580e9b66aa9fad14f1a35e5c03d486169fb6c1a1"
            },
            "downloads": -1,
            "filename": "Bootstrap-Flask-2.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "812bf54d86e47136f30f8aa2834ff466",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3841459,
            "upload_time": "2024-04-07T13:19:58",
            "upload_time_iso_8601": "2024-04-07T13:19:58.071460Z",
            "url": "https://files.pythonhosted.org/packages/7a/af/6db8af36a760e5d00a0f21c147b4ae754d77e25685b7d23464e333746809/Bootstrap-Flask-2.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-07 13:19:58",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "helloflask",
    "github_project": "bootstrap-flask",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "bootstrap-flask"
}
        
Elapsed time: 0.23798s