Utilities & Auxiliaries

We provided some auxiliary functions for Flask-DataTables.

flask_datatables.utils.render_macro(template_name_or_list, macro, **context)[source]

Evaluates and renders a macro from the template.

Parameters
  • template_name_or_list (Union[str, List[str]]) – The name of the template to be rendered, or an iterable with template names the first one existing will be rendered.

  • macro (str) – The name of macro to be called.

  • context (Any) –

Keyword Arguments

**context – The variables that should be available in the context of the template.

Return type

str

Returns

The rendered macro.

flask_datatables.utils.prepare_response(template)[source]

Prepare response object data.

The function returns a wrapper function to use the template as a factory to render HTML response blocks. The Jinja templates should have macro blocks for each target field named after render_{field_name} and takes only one argument record as the selected data model record.

Parameters

template (Union[str, List[str]]) – Path to the macro template.

Return type

Callable[[Model], ObjectData]

Returns

Prepared response object data.

See also

See flask_datatables.utils.render_macro() for more information.

flask_datatables.utils.parse_request(args=None)[source]

Parse flask.request.args as Query.

Parameters

args (Optional[ImmutableMultiDict]) – Original request arguments. The default value is inferred from request.args.

Return type

Query

Returns

Parsed query dictionary.