Version 32 (modified by 16 years ago) ( diff ) | ,
---|
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-extensions (formerly named 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 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)
-
camera-001.png
(12.0 KB
) - added by 18 years ago.
PNG version of camera-001.pdf
-
mincer-001.png
(30.4 KB
) - added by 18 years ago.
PNG version of mincer-001.pdf
-
mincer-modelviz-0.6.png
(102.3 KB
) - added by 18 years ago.
New modelviz sample image
-
modelviz.py
(3.5 KB
) - added by 17 years ago.
Updated script off of trunk @ Jun 6 2007
-
modelviz.2.py
(3.5 KB
) - added by 17 years ago.
Django Trunk GenericRelation Modify
-
modelviz.3.py
(5.4 KB
) - added by 17 years ago.
added other features.
-
modelviz.4.py
(5.6 KB
) - added by 17 years ago.
grays out blank=True fields
-
modelviz.5.py
(6.3 KB
) - added by 17 years ago.
-i, --include_models only include selected models in graph
-
modelviz.6.py
(8.1 KB
) - added by 17 years ago.
uploaded version from django-command-extensions
-
modelviz_i18n.py
(5.9 KB
) - added by 16 years ago.
Version with localized verbose_names instead of names
-
modelviz.7.py
(6.7 KB
) - added by 16 years ago.
Add exclude_models as well as include_models
-
modelviz.8.py
(7.5 KB
) - added by 16 years ago.
Added support for GeoDjango GeometryColumns and SpatialRefSys (requires fix in r9483)
Download all attachments as: .zip