Directed Acyclic Graph implementation for Django & Postgresql
Project description
Django & Postgresql-based Directed Acyclic Graphs
The main distinguishing factor for this project is that it can retrieve entire sections of a graph with far fewer queries than most other packages. The trade off is portability: it uses Postgres' Common Table Expressions (CTE) to achieve this and is therefore not compatible with other databases.
The primary purpose of this package is to build and manipulate DAGs within a Django project. If you are looking for graph analysis or visualization, this may not be the right package.
All core traversal methods (ancestors(), descendants(), path(), connected_graph(), tree methods, roots(), leaves(), edge queries, etc.) use CTE-based queries.
The package also supports CTE filters (disallow_nodes, allow_nodes, disallow_edges, allow_edges, limiting_edges_set_fk) to limit the area of the graph searched, and optional NetworkX/RustworkX/JSON export via the transforms extra. Manager-level methods connected_components() and graph_stats() provide whole-graph analytics. All traversal and predicate methods accept a convenient edge_type parameter as shorthand for limiting_edges_set_fk.
Additional graph algorithms include: topological sort, depth annotation, all-paths enumeration, lowest common ancestor (LCA), weighted shortest path, critical path (longest path), transitive reduction, and graph hashing (via NetworkX Weisfeiler-Lehman).
Demo
Quickstart example | Tutorial | Full documentation
Install
pip install django-postgresql-dag
With optional dependencies for using transformations:
pip install django-postgresql-dag[transforms]
Configuration
You can optionally configure the default maximum traversal depth for all graph queries by adding this to your Django settings:
# settings.py
DJANGO_POSTGRESQL_DAG_MAX_DEPTH = 50 # default is 20
This sets the project-wide default for all graph traversal methods (ancestors(), descendants(), path(), etc.). You can still override it per-call by passing max_depth=N to any method.
ToDo
See the checklists in issues to understand the future goals of this project.
Credits:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_postgresql_dag-2026.2.3.tar.gz.
File metadata
- Download URL: django_postgresql_dag-2026.2.3.tar.gz
- Upload date:
- Size: 54.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
741364a03144c8cb041f4c8101afce965d2634f3ce3e5c0bbdb78ae92d77fc9f
|
|
| MD5 |
ce1dfb3686505da993b8e6e6948068ab
|
|
| BLAKE2b-256 |
ec70437a015da536f87d4af3becdefa2cec296db743bf8ae18c0076111b4d437
|
File details
Details for the file django_postgresql_dag-2026.2.3-py3-none-any.whl.
File metadata
- Download URL: django_postgresql_dag-2026.2.3-py3-none-any.whl
- Upload date:
- Size: 30.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d647d56b1e190d874950008e7f1557d4a8d45505ebafc46cf652d9c38c7eac4
|
|
| MD5 |
f7c066e521a67eaa5e1242ca52a9d585
|
|
| BLAKE2b-256 |
e54c6338cb6b7edc40e51fbede4a90a902cc2f21f1d8dfc23f39346ce1ca6c14
|