Utilities & Auxiliaries¶
We provided some auxiliary functions for Flask-DataTables
.
render_macro()
renders a givenmacro
from the Jinja templatesprepare_response()
is the default built-in method forfactory
parameter ofModel.search
parse_request()
is the utility function to parse DataTables client-side query parameters from the URL
- flask_datatables.utils.render_macro(template_name_or_list, macro, **context)[source]¶
Evaluates and renders a macro from the template.
- Parameters:
- Keyword Arguments:
**context – The variables that should be available in the context of the template.
- Return type:
- 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 afterrender_{field_name}
and takes only one argumentrecord
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
asQuery
.- Parameters:
args (
Optional
[ImmutableMultiDict
]) – Original request arguments. The default value is inferred fromrequest.args
.- Return type:
- Returns:
Parsed query dictionary.