'Get the name to use for the object.'

def get_context_object_name(self, obj):

    if self.context_object_name:
        return self.context_object_name
    elif isinstance(obj, models.Model):
        return obj._meta.object_name.lower()
    else:
        return None
