The GenericForeignKey field (GFK) is a great feature provided by Django's django.contrib.contenttypes module. While a normal ForeignKey field can point to a database object of a given model, a GenericForeignKey can point to a database object of any model.
This section provides a topic overview. See also
A tested example of GFK fields and
method tests for related objects, which automatically includes also
those which are related using a GFK. non-nullable and warning before
In order to use GFKs, you must have
INSTALLED_APPS. In a Lino application we recommend to
lino.modlib.contenttypes, which is a thin wrapper around
Django's original app. Lino's version gives you additional
In Lino you can configure the cascading behaviour from the model
which defines the GFK, either by using the
allow_cascaded_delete attribute or by
defining a nullable GFK.