def get_gfk_field(model):
    for field in model._meta.virtual_fields:
        if isinstance(field, GenericForeignKey):
            return field

    raise ValueError('Unable to find gfk field on %s' % model)
dataset/ETHPy150Open coleifer/django-generic-aggregation/generic_aggregation/utils.py/get_gfk_field/original