Return the model matching the given app_label and model_name. As a shortcut, app_label may be in the form <app_label>.<model_name>. model_name is case-insensitive. Raise LookupError if no application exists with this label, or no model exists with this nam
(self, app_label, model_name=None, require_ready=True)
| 186 | return result |
| 187 | |
| 188 | def get_model(self, app_label, model_name=None, require_ready=True): |
| 189 | """ |
| 190 | Return the model matching the given app_label and model_name. |
| 191 | |
| 192 | As a shortcut, app_label may be in the form <app_label>.<model_name>. |
| 193 | |
| 194 | model_name is case-insensitive. |
| 195 | |
| 196 | Raise LookupError if no application exists with this label, or no |
| 197 | model exists with this name in the application. Raise ValueError if |
| 198 | called with a single argument that doesn't contain exactly one dot. |
| 199 | """ |
| 200 | if require_ready: |
| 201 | self.check_models_ready() |
| 202 | else: |
| 203 | self.check_apps_ready() |
| 204 | |
| 205 | if model_name is None: |
| 206 | app_label, model_name = app_label.split(".") |
| 207 | |
| 208 | app_config = self.get_app_config(app_label) |
| 209 | |
| 210 | if not require_ready and app_config.models is None: |
| 211 | app_config.import_models() |
| 212 | |
| 213 | return app_config.get_model(model_name, require_ready=require_ready) |
| 214 | |
| 215 | def register_model(self, app_label, model): |
| 216 | # Since this method is called when models are imported, it cannot |