MCPcopy
hub / github.com/django/django / get_model

Method get_model

django/apps/registry.py:188–213  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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&#x27;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

Callers 15

test_dynamic_loadMethod · 0.95
create_default_siteFunction · 0.45
get_user_modelFunction · 0.45
_create_user_objectMethod · 0.45
check_user_modelFunction · 0.45
check_models_permissionsFunction · 0.45
create_permissionsFunction · 0.45
_get_permission_metadataFunction · 0.45
database_forwardsMethod · 0.45
database_backwardsMethod · 0.45

Calls 5

check_models_readyMethod · 0.95
check_apps_readyMethod · 0.95
get_app_configMethod · 0.95
splitMethod · 0.45
import_modelsMethod · 0.45