base_extras

Module: espressodb.base.templatetags.base_extras

render_link_list([exclude])

Renders all app page links

render_field(field[, instance_name])

Returns verbose descriptor of model field

render_fields(fields[, instance_name])

Renders fields to string.

render_tree(tree, root)

Renders a model population tree to Python code.

render_version()

Returns descriptive version string

render_db_info()

Returns descriptive db string

project_name()

Returns name of the project


Additional in template functions for the base module.

get_item(dictionary, key)[source]

Extract key from dictionary

Parameters
  • dictionary (Dict[str, Any]) – The dictionary to search

  • key (str) – The key to look up

See also: https://stackoverflow.com/a/8000091

Return type

Any

project_name()[source]

Returns name of the project

Return type

str

render_db_info()[source]

Returns descriptive db string

Return type

str

Renders all app documentation page links

Return type

List[Tuple[str, str]]

Returns

Context with keys urls and documentation where each value is a list of Tuples with the reverse url name and display name.

Ignores urls which do not result in a match.

Uses the template documentation-links.html.

render_field(field, instance_name=None)[source]

Returns verbose descriptor of model field

Parameters
  • field (Field) – The field to render.

  • instance_name (Optional[str]) – The name of model instance for which the fields are written. If given, automatically insert the value for FK fields. This assumes that the FK variables are defined before this class and follow the convention columnname1_columnname2_….

Return type

str

render_fields(fields, instance_name=None)[source]

Renders fields to string.

Parameters
  • fields (List[Field]) – The fields to render.

  • instance_name (Optional[str]) – The name of model instance for which the fields are written. If given, automatically insert the value for FK fields. This assumes that the FK variables are defined before this class and follow the convention column_name1_column_name2_….

Sorts fields by being optional or not.

Return type

List[str]

Renders all app page links

Parameters

exclude – The link names to exclude.

Return type

List[Tuple[str, str]]

Returns

Context with keys urls and documentation where each value is a list of Tuples with the reverse url name and display name.

Ignores urls which do not result in a match.

Uses the template link-list.html.

Note

It is possible to give class based views the exclude_from_nav flag. If this flag is set, the view will not be rendered.

render_tree(tree, root)[source]

Renders a model population tree to Python code.

Parameters
  • tree (Dict[str, str]) – The column names ForeignKey dependency tree of the root model.

  • root (str) – The name of the root model.

Return type

Dict[str, str]

Returns

Context containing the Python code unde key content.

Uses the template tree-to-python.html.

render_version()[source]

Returns descriptive version string

Return type

str