You can’t use Django’s generic foreign key field with objects stored in a separate database
Django supports using separate databases for specified models or apps. This is done using custom database routers.
However Django’s generic foreign keys should not be used to link to instances that live in a different database from where the foreign key field will be stored.
This is because Django (up to v4.0.2 at least) assumes the database tables for
the django.contrib.contenttypes
app
are created in the same database as the instance being linked to.
But creating a django_content_types
table in multiple databases is explicitly
warned against in the Django docs:

Since generic foreign keys use a cascading database reference between the table
with the generic foreign key and the django_content_types
table, it would be
dangerous to have a separate django_content_types
table in another database
where the primary key is looked up.