Django Unleashed Book Model Diagram

Posted on with tags: django

Andrew Pinkham's Django Unleashed is a very good Django book. It covers many aspects of Django Web Framework with an example project. It is not a book for complete beginners. A reader needs to know a little Python and Django basics to get started.

The Chapter 3 of the book is about Django Models, discussing the example project models. The project has 4 models, 3 many-to-many relations, and 1 many-to-one relation. The book does not include a diagram showing the models and relations. Here is the diagram I draw in Inkscape:

django unleashed models

Here is the link to the PDF page of the diagram.

The django-extensions has a graph_models command which generates similar model diagrams.

Add the GRAPH_MODELS dictionary to the project settings file.

  'all_applications': False, 
  'group_models': True,

The extension command depends on the graphviz package and pydot/pyparsing modules. Install those dependencies in Ubuntu 18.04 and run the python ... command to generate diagram.

$sudo apt-get install graphviz
(env)$pip install pyparsing pydot

(env)$python graph_models blog organizer --pydot -o models.png

Here is the result PNG file.

django unleashed models