Skip to main content

Directed Acyclic Graph implementation for Django & Postgresql

Project description

codecov PyPI last commit Documentation Status made-with-python

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:

  1. This excellent blog post
  2. django-dag
  3. django-dag-postgresql
  4. django-treebeard-dag

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_postgresql_dag-2026.2.2.tar.gz (49.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_postgresql_dag-2026.2.2-py3-none-any.whl (29.8 kB view details)

Uploaded Python 3

File details

Details for the file django_postgresql_dag-2026.2.2.tar.gz.

File metadata

  • Download URL: django_postgresql_dag-2026.2.2.tar.gz
  • Upload date:
  • Size: 49.7 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

Hashes for django_postgresql_dag-2026.2.2.tar.gz
Algorithm Hash digest
SHA256 a6700ac1b525dba0f11ca94b95bb502cd661b4c43a14929db1dd18840257ca77
MD5 32e0935f8cbfbc449298de76a724e3f7
BLAKE2b-256 3c31a74d10cc4eb342bd3d395cf91685f73bd188c9ae78da43c270a5abbd83ef

See more details on using hashes here.

File details

Details for the file django_postgresql_dag-2026.2.2-py3-none-any.whl.

File metadata

  • Download URL: django_postgresql_dag-2026.2.2-py3-none-any.whl
  • Upload date:
  • Size: 29.8 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

Hashes for django_postgresql_dag-2026.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3db8618186cd9e2b7bf824df8c72a30f96849da0d656361ba2790078f4682782
MD5 9801513cf8c3e1e24c9d8f179301102f
BLAKE2b-256 895257b08d32f31c47a063efeac30bd3a40968babcd29bdf11950d8e3ac72f84

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page