'Clear all internal caches, for methods that alter the app registry.
This is mostly used in tests.'

def clear_cache(self):

    self.get_models.cache_clear()
    if self.ready:
        for app_config in self.app_configs.values():
            for model in app_config.get_models(include_auto_created=True):
                model._meta._expire_cache()
