Welcome | Get started | Dive into Lino | Contribute | Topics | Reference | More

lino.core.model

Defines the Model class.

See Introduction to database models, Customize delete behaviour, Disable elements of the user interface, Hide individual fields, Customize how data is formatted

Functions

pre_delete_handler(sender[, instance])

Before actually deleting an object, we override Django's behaviour concerning related objects via a GFK field.

Classes

Model(*args, **kwargs)

lino.core.model.pre_delete_handler(sender, instance=None, **kw)

Before actually deleting an object, we override Django's behaviour concerning related objects via a GFK field.

In Lino you can configure the cascading behaviour using allow_cascaded_delete.

See also GenericForeignKey fields.

It seems that Django deletes generic related objects only if the object being deleted has a GenericRelation field (according to Why won't my GenericForeignKey cascade when deleting?). OTOH this statement seems to be wrong: it happens also in my projects which do not use any GenericRelation. As test_broken_gfk shows.

TODO: instead of calling disable_delete here again (it has been called earlier by the delete action before asking for user confirmation), Lino might change the on_delete attribute of all ForeignKey fields which are not in allow_cascaded_delete from CASCADE to PROTECTED at startup.