Django ORM support
Description
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.
Technology support
| Technology | Version | Supported |
|---|---|---|
| Django ORM | 2.0 to 6.0 | ✅ |
What results can you expect?
Objects
| Icon | Description | Comment |
|---|---|---|
![]() |
Python Django Entity Python Django Unknown Entity |
Python Django Entity: created when a Django model class inheriting from django.db.models.Model is found during the analysis, or when the analyzer detects supported Django Manager APIs on a Django model class.Python Django Unknown Entity: created when a supported Django Manager API is used on a class that is not detected as a Django model class. This can happen when the model class is not analyzed or when the model class is not correctly detected by the analyzer, for example due to dynamic code or imports. |
![]() |
Python Django Entity Operation Python Django Unknown Entity Operation |
Python Django Entity Operation: created when one of the supported Django Manager APIs is used on a Django model class inheriting from django.db.models.Model.Python Django Unknown Entity Operation: created when a supported Django Manager API is used on a class that is not detected as a Django model class. |
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. |
Code examples
Django Entity
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:

Django Unknown Entity
class A():
def __init__(self):
self.models = dict()
def f(self):
unknown_model = self.models["foo"]
unknown_model.objects.filter(x=1)
Will create the following objects and links:

Supported persistence SQL databases
Supported operations
The analyzer detects Django ORM access to database operations through a model manager, such as <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:
from django.apps import apps
app = 'blog'
article_model = 'Article'
article = apps.get_model(app, article_model)
articles = article.objects.all()
| Entity Operation | Supported APIs |
|---|---|
| Select |
|
| Insert |
|
| Update |
|
| Delete |
|
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

