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

Method get_model

django/apps/config.py:224–239  ·  view source on GitHub ↗

Return the model with the given case-insensitive model_name. Raise LookupError if no model exists with this name.

(self, model_name, require_ready=True)

Source from the content-addressed store, hash-verified

222 return app_config_class(app_name, app_module)
223
224 def get_model(self, model_name, require_ready=True):
225 """
226 Return the model with the given case-insensitive model_name.
227
228 Raise LookupError if no model exists with this name.
229 """
230 if require_ready:
231 self.apps.check_models_ready()
232 else:
233 self.apps.check_apps_ready()
234 try:
235 return self.models[model_name.lower()]
236 except KeyError:
237 raise LookupError(
238 "App '%s' doesn't have a '%s' model." % (self.label, model_name)
239 )
240
241 def get_models(self, include_auto_created=False, include_swapped=False):
242 """

Callers

nothing calls this directly

Calls 2

check_models_readyMethod · 0.80
check_apps_readyMethod · 0.80

Tested by

no test coverage detected