Return a list of all installed models. By default, the following models aren't included: - auto-created models for many-to-many relations without an explicit intermediate table, - models that have been swapped out. Set the corresponding keyword a
(self, include_auto_created=False, include_swapped=False)
| 167 | # This method is performance-critical at least for Django's test suite. |
| 168 | @functools.cache |
| 169 | def get_models(self, include_auto_created=False, include_swapped=False): |
| 170 | """ |
| 171 | Return a list of all installed models. |
| 172 | |
| 173 | By default, the following models aren't included: |
| 174 | |
| 175 | - auto-created models for many-to-many relations without |
| 176 | an explicit intermediate table, |
| 177 | - models that have been swapped out. |
| 178 | |
| 179 | Set the corresponding keyword argument to True to include such models. |
| 180 | """ |
| 181 | self.check_models_ready() |
| 182 | |
| 183 | result = [] |
| 184 | for app_config in self.app_configs.values(): |
| 185 | result.extend(app_config.get_models(include_auto_created, include_swapped)) |
| 186 | return result |
| 187 | |
| 188 | def get_model(self, app_label, model_name=None, require_ready=True): |
| 189 | """ |