[](https://travis-ci.org/christabor/flask_extras)
[](https://scrutinizer-ci.com/g/christabor/flask_extras/?branch=master)
[](https://codeclimate.com/github/christabor/flask_extras)
[](https://coveralls.io/github/christabor/flask_extras?branch=master)
[](https://landscape.io/github/christabor/flask_extras/master)
# Flask Extras
Assorted useful flask views, blueprints, Jinja2 template filters, and templates/macros.
## Overall setup
As of `3.4.0`, filters and templates will automatically be registered and available through the following simple command:
```python
from flask_extras import FlaskExtras
app = Flask('myapp')
FlaskExtras(app)
```
For the old way, check out [this page](wiki/old_setup.md)
## Available features
### Views
Import them like usual:
```python
from flask_extras.views import (
statuses,
)
```
*Note:* each view must have a valid template in your apps templates dir. See each view for the required names and locations.
*Note:* each view has configuration helpers to inject or configure your app. See source for details.
### Macros
**Many more macros** are available. You can use them like so:
```html
{% from 'macros.html' import list_group, objects2table %}
```
For the most comprehensive docs, check out each [macro](flask_extras/macros/). Comment "docstrings" are inline using jinja2 comments (these are not rendered in your html).
Also, check the source and/or output to see what classes are available for style overrides.
### Statuses
Provides views for common status codes. Usage:
```python
app = statuses.inject_error_views(app)
```
See source for more.
### Decorators
See the source for more. Usage example:
```python
from flask_extras.decorators import require_headers
app.route('/')
@require_headers(['X-Foo'])
def foo():
pass
```
### Forms
#### WTForm Multi-step wizard
A WTForm extension for handling an arbitrary number of separate forms as a single, multi-step, multi-POST wizard. All state and data are handled by apps' session backend. Building forms is just like you're used to -- simple and intuitive. Just inherit the `MultiStepWizard` class and put a `__forms__` key on it, which is just a list of all the forms you want to use. *Note*: list order matters for your form steps.
Usage example:
```python
from flask.ext.wtf import FlaskForm
from flask_extras.forms.wizard import MultiStepWizard
class MultiStepTest1(FlaskForm):
field1 = StringField(validators=[validators.DataRequired()],)
field2 = IntegerField(validators=[validators.DataRequired()],)
class MultiStepTest2(FlaskForm):
field3 = StringField(validators=[validators.DataRequired()],)
field4 = IntegerField(validators=[validators.DataRequired()],)
class MyCoolForm(MultiStepWizard):
__forms__ = [
MultiStepTest1,
MultiStepTest2,
]
```
and an example route:
```python
from forms import MyCoolForm
@app.route('/', methods=['GET', 'POST'])
def index():
curr_step = request.args.get('curr_step')
form_kwargs = dict(session_key='mycustomkey')
if curr_step is not None:
form_kwargs.update(curr_step=curr_step)
form = forms.MyCoolForm(**form_kwargs)
kwargs = dict(form=form)
if request.method == 'POST':
if form.validate_on_submit():
if form.is_complete():
data = form.alldata(combine_fields=True, flush_after=True)
flash('Form validated and complete! data = {}'.format(data),
'success')
return jsonify(data)
else:
flash('Great job, but not done yet ({} steps remain!).'.format(form.remaining))
else:
flash('Invalid form data.', 'error')
return render_template('index.html', **kwargs)
```
and an example html page (using the [wtform_form](flask_extras/macros/macros.html) macro also available):
```html
{% if form.is_complete() %}
<span class="well">Complete!</span>
{% else %}
<ul class="list-inline">
{% for step in form.steps %}
<li>
{% if step == form.curr_step %}
<strong class="lead label label-info">current {{ step }}</strong>
{% else %}
<a href="{{ url_for('app.index') }}?curr_step={{ step }}">{{ step }}</a>
{% endif %}
{% if not loop.last %}
/
{% endif %}
</li>
{% endfor %}
</ul>
{{ wtform_form(form,
classes=['form', 'form-horizontal'],
btn_classes=['btn btn-primary', 'btn-lg'],
align='right',
action=url_for('app.index'),
method='POST',
reset_btn=False,
horizontal=True,
) }}
{% endif %}
```
Metadata
Release files for flask_extras 4.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| flask_extras-4.0.3.tar.gz | 39.1 kB | Without provenance | Details for flask_extras-4.0.3.tar.gz |
Release files / flask_extras-4.0.3.tar.gz
| Download URL | flask_extras-4.0.3.tar.gz |
|---|---|
| Size | 39.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0f8acd380f783cfea2c5d4d98dd2001ed9d0fdef743205a0c9e430e0ce107d12
|
|
BLAKE2b-256 checksum How to use checksums |
5904618b8074a79b572710287cc913d826205938e063cebe1ed7262e192a792d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for flask_extras 4.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.