Converting Django models into Graphviz DOT files
Inspired by this nice hack by Matt Biddulph, this is a Python script that generates a Graphviz DOT file for quick visualizations of Django model definitions.
Source code
View online or download from Subversion repository (you could also set it as a svn:external on your repository to keep up to date with the latest revisons.)
Checkout
svn co svn://unicoders.org/unicoders/django/trunk/utils/ modelviz
Examples
MC Minerali Ceramici
Command
Once you use this python script to generate the dot file (app.dot), 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-command-extensions already 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 more easy and clear to view.
Usage:
# download django-command-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
- camera-001.png (12.0 kB) -
PNG version of camera-001.pdf
, added by Simon Willison on 08/06/06 06:03:20. - mincer-001.png (30.4 kB) -
PNG version of mincer-001.pdf
, added by Simon Willison on 08/06/06 06:04:06. - mincer-modelviz-0.6.png (102.3 kB) -
New modelviz sample image
, added by verbosus on 11/01/06 15:40:39. - modelviz.py (3.5 kB) -
Updated script off of trunk @ Jun 6 2007
, added by jimmy@jamespells.com on 06/06/07 20:08:24. - modelviz.2.py (3.5 kB) -
Django Trunk GenericRelation? Modify
, added by QingFeng on 06/11/07 03:37:19. - modelviz.3.py (5.4 kB) -
added other features.
, added by André Campos on 06/20/07 06:27:59. - modelviz.4.py (5.6 kB) -
grays out blank=True fields
, added by jfindlay@gmail.com on 07/12/07 17:54:59. - modelviz.5.py (6.3 kB) -
-i, --include_models only include selected models in graph
, added by alexander@houben.ch on 03/19/08 13:28:24. - modelviz.6.py (8.1 kB) -
uploaded version from django-command-extensions
, added by trbs on 05/10/08 18:30:43.
