This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Assorted useful flask views, blueprints, Jinja2 template filters, and templates/macros

Project Description
[![Codacy Badge](](
[![Build Status](](
[![Scrutinizer Code Quality](](
[![Code Climate](](
[![Coverage Status](](
[![Code Health](](

# 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:

from flask_extras import FlaskExtras
app = Flask('myapp')

For the old way, check out [this page](wiki/

## Available features

### Views

Import them like usual:

from flask_extras.views import (

*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:

{% 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:

app = statuses.inject_error_views(app)

See source for more.

### Decorators

See the source for more. Usage example:

from flask_extras.decorators import require_headers

def foo():

### 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:

from 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__ = [

and an example route:

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 = 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),
return jsonify(data)
flash('Great job, but not done yet ({} steps remain!).'.format(form.remaining))
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):

{% if form.is_complete() %}
<span class="well">Complete!</span>
{% else %}
<ul class="list-inline">
{% for step in form.steps %}
{% 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 %}
{% endfor %}
{{ wtform_form(form,
classes=['form', 'form-horizontal'],
btn_classes=['btn btn-primary', 'btn-lg'],
) }}
{% endif %}
Release History

Release History

This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
flask_extras-4.0.3.tar.gz (39.1 kB) Copy SHA256 Checksum SHA256 Source Mar 3, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting