MCPcopy
hub / github.com/tortoise/tortoise-orm / get_model

Method get_model

tortoise/context.py:418–436  ·  view source on GitHub ↗

Retrieve a model by app label and model name. Args: app_label: The app label (e.g., "models"). model_name: The model class name (e.g., "User"). Returns: The model class. Raises: ConfigurationError: If context not ini

(self, app_label: str, model_name: str)

Source from the content-addressed store, hash-verified

416 await generate_schema_for_client(connection, safe)
417
418 def get_model(self, app_label: str, model_name: str) -> type[Model]:
419 """
420 Retrieve a model by app label and model name.
421
422 Args:
423 app_label: The app label (e.g., "models").
424 model_name: The model class name (e.g., "User").
425
426 Returns:
427 The model class.
428
429 Raises:
430 ConfigurationError: If context not initialized or model not found.
431 """
432 if self._apps is None:
433 raise ConfigurationError(
434 "Context not initialized. Call init() before accessing models."
435 )
436 return self._apps.get_model(app_label, model_name)
437
438 def db(self, connection_name: str | None = None) -> BaseDBAsyncClient:
439 """

Calls 1

ConfigurationErrorClass · 0.90