Commit 6f60919a authored by Serge S. Koval's avatar Serge S. Koval

Merge pull request #316 from ArtemSerga/parent

Add extra documentation for `column_formatters`
parents 59e03b4d 16c9eeb2
......@@ -89,6 +89,18 @@ class BaseModelView(BaseView, ActionsMixin):
class MyModelView(BaseModelView):
column_formatters = dict(price=lambda v, c, m, p: m.price*2)
or using Jinja2 `macro` in template::
from flask.ext.admin.model.template import macro
class MyModelView(BaseModelView):
column_formatters = dict(price=macro('render_price'))
# in template
{% macro render_price(model, column) %}
{{ model.price * 2 }}
{% endmacro %}
The Callback function has the prototype::
def formatter(view, context, model, name):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment