django-app-tree

Command line tool to generate graphs of app dependencies in Django apps


License
Other
Install
pip install django-app-tree==0.1.0

Documentation

django-app-tree

This is a dependency checking / generating tool that highlights dependencies between apps.

One type of dependency is that models from app A have a reference to a model in app B.

Another one is simply where code is called.

The tool is a Django management command that can simply be called by

./manage.py dependency_tree

especially

./manage.py dependency_tree --help

might be helpful.

The final output is a graphviz file between the "-----------" lines

Just copy it into an empty file and run the graphviz (https://graphviz.org/) compiler, e.g. with dot dependencies.dot -Tpdf -o test.pdf to generate a PDF.

Example commands are:

./manage.py dependency_tree --contains-app=test --with-labels

to show all relations of the "test" app (from / to) and add the name of the models, functions or classes as labels.

Or:

./manage.py dependency_tree --from-app=example --with-labels

to show which apps the "example" app calls code from.

To get the full picture of all relations, just call:

./manage.py dependency_tree --with-labels

BUT beware... you might not like what you see :)

Development

Install the pre-commit hooks:

pre-commit install
pre-commit install --hook-type commit-msg
pre-commit install --hook-type pre-push

Local python setup:

python3.10 -m venv .
source ./bin/activate
pip install --upgrade pip
pip install --editable .[dev,test,docs]