              # instances' PK in order to match up instances:
              object_id_converter = instances[0]._meta.pk.to_python
              return (
                  queryset.filter(query),
                  lambda relobj: (
                      object_id_converter(getattr(relobj, self.object_id_field_name)),
                      getattr(relobj, content_type_id_field_name),
                  ),
 
</s> remove                     relobj.content_type_id
 </s> add                     getattr(relobj, content_type_id_field_name),
            content_type_id_field_name = '%s_id' % self.content_type_field_name
              # instances' PK in order to match up instances:
              object_id_converter = instances[0]._meta.pk.to_python
            content_type_id_field_name = '%s_id' % self.content_type_field_name
              return (
                  queryset.filter(query),
                  lambda relobj: (
                      object_id_converter(getattr(relobj, self.object_id_field_name)),
                      getattr(relobj, content_type_id_field_name),
                  ),
keep add keep keep keep keep keep keep
 Fixed #31190 -- Fixed prefetch_related() crash for GenericForeignKey with custom ContentType foreign key.

Regression in dffa3e1992562ba60512d96d1eb5859ffff2ceb5. 
django/contrib/contenttypes/fields.py