Filtering & Key Inference¶
Control which entities and model kinds appear in the diagram, and derive keys for keyless models.
Excluding Entities¶
Use --exclude to drop tables/entities from the diagram. Each pattern is a
case-sensitive glob tested
against both the class name and the table name â an entity is excluded
if either matches. Any relationships pointing at an excluded entity are dropped
too, so no dangling lines remain.
# Exclude all link tables (class names ending in "Link")
erdify ./src/database --exclude '*Link'
# Exclude by table name, with multiple patterns
erdify ./src/database --exclude audit_log 'tmp_*' Session
đĄ Quote patterns containing
*so your shell doesn't expand them.
Excluding by Path (--exclude-paths)¶
--exclude filters by name after parsing. To skip whole folders before
the scan â e.g. so erdify never reads a virtualenv's third-party models.py â
use --exclude-paths. Patterns are case-sensitive globs matched against each
models.py path relative to the input or any single path segment.
# Skip migrations and a legacy app, anywhere in the tree
erdify ./backend --exclude-paths migrations legacy
# Precise path glob
erdify ./backend --exclude-paths 'apps/experimental/*'
By default erdify already auto-skips models.py under common non-project
directories â site-packages, .venv, venv, env, virtualenv,
node_modules, __pycache__, .git, .tox, .mypy_cache, .pytest_cache â
so running on a Django project picks up only your own apps, not installed
packages like django.contrib.*, constance or django_celery_beat. Pass
--no-default-excludes to scan those directories too.
Filtering by Model Kind¶
Use --sources to restrict the diagram to specific model frameworks. By default
all recognized kinds are drawn (sqlmodel, sqlalchemy, django, dataclass,
pydantic). This is the precise alternative to --exclude when you want a pure
DB-table ERD and don't want Pydantic DTOs or @dataclass query wrappers to leak in.
# Only real DB tables â drops Pydantic/dataclass models entirely
erdify ./src/database --sources sqlmodel sqlalchemy
# ORM tables plus your Pydantic schemas, but no dataclasses
erdify ./src/database --sources sqlmodel pydantic
đĄ
--sourcesfilters by kind;--excludefilters by name. Combine them freely.
Inferring keys (--infer-keys)¶
Pydantic models and dataclasses have no database key concept. By default all
fields are rendered as plain columns and relationships come only from nested
model references. If your models follow a database-like naming convention, pass
--infer-keys to derive keys from field names:
- a field named
idâ primary key - a field named
<x>_idâ foreign key targeting table<x>
# Plain columns (default)
erdify ./src/schemas
# Infer PK/FK from id / <x>_id naming
erdify ./src/schemas --infer-keys
âšī¸
--infer-keysonly affects Pydantic/dataclass models. SQLModel and SQLAlchemy keys are always read from the explicit definitions and never overridden.