Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | 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
|
Before actually deleting an object, we override Django's behaviour concerning related objects via a GFK field. |
Classes
|
- 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 inallow_cascaded_delete
fromCASCADE
toPROTECTED
at startup.