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.

Demo

Quickstart example

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.1.tar.gz (39.4 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.1-py3-none-any.whl (24.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_postgresql_dag-2026.2.1.tar.gz
  • Upload date:
  • Size: 39.4 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.1.tar.gz
Algorithm Hash digest
SHA256 e70d1c0cbe8c3c171fab8e1cc8f670bfbe56c2a2278ea441737b10206f220f78
MD5 47aeff50443a513bd1b40dbff8a4de76
BLAKE2b-256 555b9e8408360e6863c670c8eae5b270b42a3bc5644d76243581f8a677cfa4e4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: django_postgresql_dag-2026.2.1-py3-none-any.whl
  • Upload date:
  • Size: 24.6 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b15e6c0e88fd82cb85ffafa182c399a746153dd2e90c950a0ff4006274b195c1
MD5 fdcb50bbfb2882e3d5b4eb6e6787e879
BLAKE2b-256 3e42aa90c12e1082cce810a1b61899d453a781e72e320186dae641db67afbf99

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