diff --git a/django/db/models/loading.py b/django/db/models/loading.py
index f86b691..bc62aa0 100644
a
|
b
|
class AppCache(object):
|
132 | 132 | self._populate() |
133 | 133 | return self.app_errors |
134 | 134 | |
135 | | def get_models(self, app_mod=None, include_auto_created=False): |
| 135 | def get_models(self, app_mod=None, include_auto_created=False, include_deferred=False): |
136 | 136 | """ |
137 | 137 | Given a module containing models, returns a list of the models. |
138 | 138 | Otherwise returns a list of all installed models. |
… |
… |
class AppCache(object):
|
141 | 141 | explicit intermediate table) are not included. However, if you |
142 | 142 | specify include_auto_created=True, they will be. |
143 | 143 | """ |
144 | | cache_key = (app_mod, include_auto_created) |
| 144 | cache_key = (app_mod, include_auto_created, include_deferred) |
145 | 145 | try: |
146 | 146 | return self._get_models_cache[cache_key] |
147 | 147 | except KeyError: |
… |
… |
class AppCache(object):
|
155 | 155 | model_list.extend(app_entry.values()) |
156 | 156 | if not include_auto_created: |
157 | 157 | model_list = filter(lambda o: not o._meta.auto_created, model_list) |
| 158 | if not include_deferred: |
| 159 | model_list = filter(lambda o: not o._deferred, model_list) |
158 | 160 | self._get_models_cache[cache_key] = model_list |
159 | 161 | return model_list |
160 | 162 | |
diff --git a/tests/regressiontests/defer_regress/models.py b/tests/regressiontests/defer_regress/models.py
index a1cd197..23d855b 100644
a
|
b
|
False
|
132 | 132 | >>> i2._deferred # Item must still be non-deferred |
133 | 133 | False |
134 | 134 | |
| 135 | # Regression for #11936 - loading.get_models should not return deferred models by default. |
| 136 | >>> from django.db.models.loading import get_models |
| 137 | >>> get_models(models.get_app('defer_regress')) |
| 138 | [<class 'regressiontests.defer_regress.models.Item'>, <class 'regressiontests.defer_regress.models.RelatedItem'>, <class 'regressiontests.defer_regress.models.Child'>, <class 'regressiontests.defer_regress.models.Leaf'>] |
| 139 | |
135 | 140 | # Finally, we need to flush the app cache for the defer module. |
136 | 141 | # Using only/defer creates some artifical entries in the app cache |
137 | 142 | # that messes up later tests. Purge all entries, just to be sure. |