Skip to main content

Add initial entities

New in v13.2.0

Create initial entities by means of the initial_entities variable in

Sometimes it is desirable to begin with one or more initial entities when starting the app (the demo app is such an example). In case of a tree-type app it is even required to have at least one initial entity from which the user can work.

Initial entities can be set by means of the initial_entities variable in, which is a list of InitialEntity objects. For example, adding an entity with name "An example entity" of type "ExampleType" would look like:

from viktor import InitialEntity

class ExampleType(ViktorController):

initial_entities = [
InitialEntity("ExampleType", name="An example entity", params=...)

On your development workspace, the initial entities including their children are applied on every start. On a production workspace, however, only the top level entities are applied the first time the workspace is created.

Click to see all available InitialEntity arguments

InitialEntity has the following arguments:

  • entity_type_name (obligatory): Refers to the class name of the entity-type's controller (or its alias).

  • name (obligatory): Name of the entity which is shown in the interface.

  • params:

    params of the initial entity. If not defined, the default params will be set.

    Assume we have a parametrization with inputs width and length, the initial values can be set using a dictionary notation:

    InitialEntity(..., params={"width": 300, "length": 500})

    or by pointing to a .json file located relative to the app file:

    InitialEntity(..., params='initial_dimensions.json')

    with initial_dimensions.json:

    "width": 300,
    "length": 500
  • children (tree-type app only)

    List of children defined as InitialEntity objects. If not defined, no children will be added. Each child must be a valid child-type of its parent (i.e. the child-type must be defined as one of the children on the parent controller).

    InitialEntity("ParentType", ..., children=[
    InitialEntity("ChildType", ...),
  • show_on_dashboard (tree-type app only, only on top-level entities)

    This flag controls which top-level entities are shown as cards on the dashboard (default=True)