Version 36 (modified by k.art@…, 12 years ago) ( diff )

linked site is offline

Converting Django models into Graphviz DOT files

This is a Python script that generates a Graphviz DOT file for quick visualizations of Django model definitions.

Source code

The Django-extensions version seems to be most up-to-date. You only need this file, not the whole project:

http://github.com/django-extensions/django-extensions/blob/master/django_extensions/management/modelviz.py

Examples

MC Minerali Ceramici

mincer example

Command

python modelviz.py myapp myotherapp > app.dot

For more options, run with --help

Once you use this python script to generate the dot file (app.dot), you should be able to open it with Graphviz. To convert to a png, ensure you have dot installed (part of Graphviz), and issue:

dot app.dot -Tpng -o app.png

Other References

You might also be interested in this Django app by Andrew Barilla from which I borrowed some ideas, that displays the graphviz results directly from the web.

Django-extensions (formerly named Django-command-extensions) provides a command to visualize your models. Using an improved version of the modelviz script. It also includes/supports grouping of your Django applications. Which will group all models of a single app together. This makes larger projects much easier and clearer to view.

Usage:

 # download django-extensions and include it in your app.
 $ ./manage.py graph_models -a -g -o my_project.png

Feedback

Please direct all feedback to Antonio Cavedoni.

Attachments (12)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.
Back to Top