extensions.rst
This file
Path
docs/extensions.rst
48 lines · 1.8 KiB
Last changed by
Reworded before 0.8 ext docs.Armin Ronacherbefore adoption4573715
History of this fileTake it
1Flask Extensions2================34Flask extensions extend the functionality of Flask in various different5ways. For instance they add support for databases and other common tasks.67Finding Extensions8------------------910Flask extensions are listed on the `Flask Extension Registry`_ and can be11downloaded with ``easy_install`` or ``pip``. If you add a Flask extension12as dependency to your ``requirements.rst`` or ``setup.py`` file they are13usually installed with a simple command or when your application installs.1415Using Extensions16----------------1718Extensions typically have documentation that goes along that shows how to19use it. There are no general rules in how extensions are supposed to20behave but they are imported from common locations. If you have an21extension called ``Flask-Foo`` or ``Foo-Flask`` it will be always22importable from ``flask.ext.foo``::2324 from flask.ext import foo2526Flask Before 0.827----------------2829If you are using Flask 0.7 or earlier the :data:`flask.ext` package will not30exist, instead you have to import from ``flaskext.foo`` or ``flask_foo``31depending on how the extension is distributed. If you want to develop an32application that supports Flask 0.7 or earlier you should still import33from the :data:`flask.ext` package. We provide you with a compatibility34module that provides this package for older versions of Flask. You can35download it from github: `flaskext_compat.py`_3637And here is how you can use it::3839 import flaskext_compat40 flaskext_compat.activate()4142 from flask.ext import foo4344Once the ``flaskext_compat`` module is activated the :data:`flask.ext` will45exist and you can start importing from there.4647.. _Flask Extension Registry: http://flask.pocoo.org/extensions/48.. _flaskext_compat.py: https://github.com/mitsuhiko/flask/raw/master/scripts/flaskext_compat.py