AI ORM Toolkit¶
orm_toolkit
¶
get_project_app_labels()
¶
Return sorted app labels for project-local Django apps (excluding third-party).
Filters out apps installed via site-packages, keeping only those whose
path is under settings.BASE_DIR.
Returns:
| Type | Description |
|---|---|
|
list[str]: Sorted app label strings. |
get_app_models_summary(allowed_apps=None)
¶
Generate a text summary of project apps and their models for use in LLM prompts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
allowed_apps
|
Optional list of app labels to include. Defaults to all project apps. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
Multi-line string with one line per app listing its model names. |
list_models_and_fields(app_label=None, allowed_apps=None)
¶
List available Django models and their fields.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_label
|
Optional[str]
|
Filter to a specific app (e.g. 'properties'). |
None
|
allowed_apps
|
Optional[List[str]]
|
List of app labels to include. Defaults to project apps. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
JSON string with model schemas. |
query_model(model_name, options=None, allowed_apps=None)
¶
Query a Django model using ORM filters and return results as JSON.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
str
|
Model identifier as |
required |
options
|
Optional[dict]
|
Dict with query options. All keys are optional:
|
None
|
allowed_apps
|
Optional[List[str]]
|
List of app labels permitted for querying. Defaults to
project apps (auto-detected from |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
JSON string. On success, contains |
str
|
|
|
str
|
contains |