'For a given model string (e.g. "auth.User"), return the name of the
corresponding settings name if it refers to a swappable model. If the
referred model is not swappable, return None.
This method is decorated with lru_cache because it\'s performance
critical when it comes to migrations. Since the swappable settings don\'t
change after Django has loaded the settings, there is no reason to get
the respective settings attribute over and over again.'

@functools.lru_cache(maxsize=None)
def get_swappable_settings_name(self, to_string):

    for model in self.get_models(include_swapped=True):
        swapped = model._meta.swapped
        if (swapped and (swapped == to_string)):
            return model._meta.swappable
        if (model._meta.swappable and (model._meta.label == to_string)):
            return model._meta.swappable
    return None
