Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More

Customize how data is created

Lino provides serveral ways for customizing how to insert rows into the database.

class lino.core.model.Model
classmethod disable_create(self, ar)

Return a veto message if you want to refuse creating rows on this model in the given action request even when permission has been given.

The default implementation returns None, which means that there is no veto.

The lino_xl.lib.accounting.VoucherItem mixin uses this to disable creating new items in a registered voucher.

on_create(self)

Override this to set default values that depend on the request.

The difference with Django’s pre_init and post_init signals is that (1) you override the method instead of binding a signal and (2) you get the action request as argument.

Used e.g. by lino_xl.lib.notes.Note.

after_ui_create(self, ar)

Hook to define custom behaviour to run when a user has created a new instance of this model.

submit_insert

The SubmitInsert action to be executed when the when the users submits an insert window.

See lino.mixins.dupable for an example of how to override it.

create_from_choice(cls, text)

Called when a learning combo has been submitted. Create a persistent database object if the given text contains enough information.

choice_text_to_dict(cls, text)

Return a dict of the fields to fill when the given text contains enough information for creating a new database object.

class lino.core.actors.Actor
allow_create = True

If this is False, the table won’t have any insert_action.

get_create_permission(self, ar)

Dynamic test per request.

This is being called only when allow_create is True.