Search code examples
pythondjangoumlclass-diagram

How to make a class diagram for a django project?


I have this Django project that contains several applications , each one contains (apps, models, forms, views, urls, tests) files. the question is what is the structure I should follow to design the class diagram for this and what are the relations among the apps?


Solution

  • For someone new to the system, it's not uncommon to want an architectural overview and in general docs are lacking in that respect, so I understand why you're asking.

    As Thomas mentions, Django follows the MVC pattern, except that your controllers are your URLs and to some extent, Middlewares and WSGI interface.

    Your initial design should focus on models. Models will contain all the business logic. Views gather the information from the models and urls combined with forms pass user information to views.

    But the application's heart are it's models, so good class diagrams of the models (and a good model design) will allow you to see what the project can and can't do and how it's done.

    For an example, take a look at Mezzanine's model graph, which is a CMS written on top of Django. And it's model graph is autogenerated.