Deletes and auto-created cohort named after the instance.

def auto_delete_cohort(instance, **kwargs):
    "Deletes and auto-created cohort named after the instance."
    cohorts = Cohort.objects.filter(autocreated=True)

    if isinstance(instance, Project):
        cohorts = cohorts.filter(project=instance)
    elif isinstance(instance, Batch):
        cohorts = cohorts.filter(batch=instance)
    else:
        return

    count = cohorts.count()
    cohorts.delete()
    log.info('Delete {0} autocreated cohorts for {1}'.format(count, instance))