Django ORM support
Introduction
Django ORM is an Object-Relational Mapping framework that is part of the Django web framework. It provides a high-level interface to interact with databases using Python objects instead of SQL queries.
The analyzer detects Django ORM method calls made on model managers, creates corresponding objects and links database operations.
Examples
Model definition: countries/models.py
from django.db import models
class Country(models.Model):
...
CRUD operation using Django ORM:
import django
from countries.models import Country
class X:
def __init__(self):
self.FR = Country.objects.get(id="FR")
Will create the following objects and links:

Objects
- a
Django Entityobject is created when a Django model class inheriting fromdjango.db.models.Modelis found during the analysis, or when the analyzer detects supported Django Manager APIs on a Django model class - a
Django Entity Operationobject is created when one of the supported Django Manager APIs is used on a Django model class inheriting fromdjango.db.models.Model.
| Icon | Description |
|---|---|
![]() |
Python Django Entity |
![]() |
Python Django Entity Operation |
Supported persistence SQL databases
Supported operations
The analyzer detects Django ORM access to database operations through a model manager: <Model>.objects.<API method>.
To get model classes dynamically, django.apps.apps.get_model() and django.apps.AppConfig.get_model() are supported, when the name can be resolved to a string:
app = 'blog'
article_model = 'Article'
article = apps.get_model(app, article_model)
articles = article.objects.all()
| Entity Operation | Supported APIs |
|---|---|
| Select |
|
| Insert |
|
| Update |
|
| Delete |
|
Supported links
| Link Type | Caller type | Callee type | Comment |
|---|---|---|---|
| callLink |
|
|
|
| relyonLink |
|
|
|
| useSelectLink |
|
|
Created by SQL Analyzer when DDL source files are analyzed or by Missing tables for Python when the object is not analyzed. |
| useInsertLink |
|
|
Created by SQL Analyzer when DDL source files are analyzed or by Missing tables for Python when the object is not analyzed. |
| useUpdateLink |
|
|
Created by SQL Analyzer when DDL source files are analyzed or by Missing tables for Python when the object is not analyzed. |
| useDeleteLink |
|
|
Created by SQL Analyzer when DDL source files are analyzed or by Missing tables for Python when the object is not analyzed. |
Known limitations
The following features are not supported:
- custom managers with overridden methods
- custom table names in custom managers: the name of the class inheriting from
django.db.models.Modelis used as table name - Q() objects for complex queries

