def METHOD_NAME(self, request, obj=None):
    if obj is not None and Layer.objects.filter(
            datasource__contains=obj.id).count() > 0:
        msg = _("Authentication configuration {} can not be deleted because one or more layers are using it: {}").format(obj.id,
                                                                                                                         ', '.join([l.name for l in Layer.objects.filter(datasource__contains=obj.id)]))
        self.message_user(request, msg, messages.WARNING)
    return super(QgisAuthAdmin, self).METHOD_NAME(request, obj) and (
        not obj or Layer.objects.filter(
            datasource__contains=obj.id).count() == 0
    )