Enable a different set of installed apps for get_app_config[s]. installed must be an iterable in the same format as INSTALLED_APPS. set_installed_apps() must be balanced with unset_installed_apps(), even if it exits with an exception. Primarily used as a r
(self, installed)
| 337 | self.clear_cache() |
| 338 | |
| 339 | def set_installed_apps(self, installed): |
| 340 | """ |
| 341 | Enable a different set of installed apps for get_app_config[s]. |
| 342 | |
| 343 | installed must be an iterable in the same format as INSTALLED_APPS. |
| 344 | |
| 345 | set_installed_apps() must be balanced with unset_installed_apps(), |
| 346 | even if it exits with an exception. |
| 347 | |
| 348 | Primarily used as a receiver of the setting_changed signal in tests. |
| 349 | |
| 350 | This method may trigger new imports, which may add new models to the |
| 351 | registry of all imported models. They will stay in the registry even |
| 352 | after unset_installed_apps(). Since it isn't possible to replay |
| 353 | imports safely (e.g. that could lead to registering listeners twice), |
| 354 | models are registered when they're imported and never removed. |
| 355 | """ |
| 356 | if not self.ready: |
| 357 | raise AppRegistryNotReady("App registry isn't ready yet.") |
| 358 | self.stored_app_configs.append(self.app_configs) |
| 359 | self.app_configs = {} |
| 360 | self.apps_ready = self.models_ready = self.loading = self.ready = False |
| 361 | self.clear_cache() |
| 362 | self.populate(installed) |
| 363 | |
| 364 | def unset_installed_apps(self): |
| 365 | """Cancel a previous call to set_installed_apps().""" |