8000 Include --app-style to the graph models documentation by ahmad88me · Pull Request #1925 · django-extensions/django-extensions · GitHub
[go: up one dir, main page]

Skip to content

Include --app-style to the graph models documentation #1925

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions docs/graph_models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,34 @@ Documentation on how to create dot files can be found here: https://www.graphviz
the Django app *django-template-minifier* this automatically removed the newlines before/after
template tags even for non-HTML templates which leads to a malformed file.


App-based Styling
-----------------

You can style models by app to visually distinguish them in the generated graph. This is useful when working with multiple apps that have interrelated models.

To use this feature, provide a JSON file specifying styles for each app. You can either:

- Place a `.app-style.json` file in the project root, or
- Use the `--app-style` command line option to specify a path to the file::

$ ./manage.py graph_models -a --app-style path/to/style.json -o styled_output.png

The JSON file should map app labels to style dictionaries. For example:

.. code-block:: json

{
"app1": {"bg": "#341b56"},
"app2": {"bg": "#1b3956"},
"django.contrib.auth": {"bg": "#561b4c"}
}

Currently, the supported style option is `bg` (background color), but the system is designed to be extended in the future with support for additional styling such as font, shape, or border.

This feature allows you to generate a single graph that highlights model groupings by app while still showing relationships across apps.


Example Usage
-------------

Expand All @@ -98,6 +126,9 @@ image by using the *graph_models* command::
# Create a PNG image file called my_project_visualized.png with application grouping
$ ./manage.py graph_models -a -g -o my_project_visualized.png

# Create a PNG with per-app styling
$ ./manage.py graph_models -a --app-style path/to/style.json -o my_styled_project.png

# Same example but with explicit selection of pygraphviz or pydot
$ ./manage.py graph_models --pygraphviz -a -g -o my_project_visualized.png
$ ./manage.py graph_models --pydot -a -g -o my_project_visualized.png
Expand Down
0