diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-12-28 20:13:08 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-12-28 20:37:42 +0100 |
| commit | bbdf01e00aed1e86f6aaeba81065be21af35d415 (patch) | |
| tree | b4bc4b0ebf1bebaf4636c764f43ee48cd2686d7a /django/apps | |
| parent | 81a5e35c8d357051e558e6f0d1b6ff7a7523a537 (diff) | |
Populated non-master app registries.
This removes the gap between the master app registry and ad-hoc app
registries created by the migration framework, specifically in terms
of behavior of the get_model[s] methods.
This commit contains a stealth feature that I'd rather not describe.
Diffstat (limited to 'django/apps')
| -rw-r--r-- | django/apps/base.py | 2 | ||||
| -rw-r--r-- | django/apps/registry.py | 18 |
2 files changed, 11 insertions, 9 deletions
diff --git a/django/apps/base.py b/django/apps/base.py index 40b72c9448..e0d637c96e 100644 --- a/django/apps/base.py +++ b/django/apps/base.py @@ -53,7 +53,7 @@ class AppConfig(object): self.models = None def __repr__(self): - return '<AppConfig: %s>' % self.label + return '<%s: %s>' % (self.__class__.__name__, self.label) @classmethod def create(cls, entry): diff --git a/django/apps/registry.py b/django/apps/registry.py index 42affbbc13..6556fbf852 100644 --- a/django/apps/registry.py +++ b/django/apps/registry.py @@ -27,9 +27,8 @@ class Apps(object): if master and hasattr(sys.modules[__name__], 'apps'): raise RuntimeError("You may create only one master registry.") - # When master is set to False, the registry isn't populated from - # INSTALLED_APPS and ignores the only_installed arguments to - # get_model[s]. + # When master is set to False, the registry ignores the only_installed + # arguments to get_model[s]. self.master = master # Mapping of app labels => model names => model classes. Every time a @@ -48,9 +47,9 @@ class Apps(object): # set_available_apps and set_installed_apps. self.stored_app_configs = [] - # Internal flags used when populating the master registry. - self._apps_loaded = not self.master - self._models_loaded = not self.master + # Internal flags used when populating the registry. + self._apps_loaded = False + self._models_loaded = False # Pending lookups for lazy relations. self._pending_lookups = {} @@ -82,8 +81,11 @@ class Apps(object): # Therefore we simply import them sequentially. if installed_apps is None: installed_apps = settings.INSTALLED_APPS - for app_name in installed_apps: - app_config = AppConfig.create(app_name) + for entry in installed_apps: + if isinstance(entry, AppConfig): + app_config = entry + else: + app_config = AppConfig.create(entry) self.app_configs[app_config.label] = app_config self.get_models.cache_clear() |
