Saturday, February 14, 2015

UML Diagrams in Django

Recently I've been working on a database project for Grad class.  I needed to generate a UML diagram as a milestone for the project.  I've always felt like doing a "Rough Draft" of anything was like doing double work - so I thought it would be cool if I could programmatically generate a UML from my python models.

It turns out other people have had this idea and done a nice job of implementing it with Pyreverse.

Getting started you'll need:

On Ubuntu:
sudo apt-get install graphvix libgraphviz-dev python-dev
pip install pylint pygraphviz
On OSX: (I found it easiest to use Homebrew)
brew install graphviz 
pip install pylint pygraphviz  
I also added django-extentions to my project to clean up some of the meta data from django.

The result: (where HospiPal is the name of the app I'd like modeled)
python manage.py graph_models -g -e -l dot -o django.png HospiPal


Personally, I find this graph beautiful.  Saves me quite a bit of time building UML models as well.

References:
Visualize Your Classes Post

No comments:

Post a Comment