Giter Club home page Giter Club logo

django-diagram's Introduction

django-diagram

Generate an Entity Relationship Diagram for a Django project in Mermaid format

logo

Installation

You can install via pip:

pip install django-diagram

Usage

Navigate to the directory containing your Django project (the folder containing manage.py) and run:

python -m django_diagram

The following options are available:

--settings=project.settings.local - The dotted path to the settings module (either this option must be provided or the DJANGO_SETTINGS_MODULE environment variable must be set)

--title="My Title" - The title to use for the diagram

--app=app_name - Restrict to only a particular Django app. If there are related models outside of this app they will be represented just by a single box rather than showing all the model attributes (see the example below).

--output=diagram.txt - The output file to write the mermaid definition, if this option is not provided the output will be written to stdout

Rendering the diagram

For a list of integrations and plugins that will render the diagram from the mermaid definition see the mermaid documentation.

For example, many Markdown renderers (including GitHub) will render the diagram if you wrap the mermaid definition in a code block with the language set to mermaid:

```mermaid
---
Django ER Diagram
---
erDiagram
Doggo {
    BigAutoField id
    CharField name
}
```

Example

Example Diagram

django-diagram's People

Contributors

gen-qr avatar nick-solly avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

django-diagram's Issues

Various suggestions

Hey ! Neat little app !! Thanks !!

Here are some suggestions, happy to create issues for those you think are interesting, I could maybe contribute some if you're accepting PRs.

  • Currently, the diagram ignores inheritance. It simply shows all models with all inherited fields, as separate entities.
  • Why not a Django management command ? Indeed a little bit more config to do (need to list it on INSTALLED_APPS), but it's more djangoic
  • Oftentimes, attributes are not so interesting when compared to relation. A --no-attributes option would be nice for such cases when there are too many attributes (keep only the primary / unique fields, and display something like 38 more attributes)
  • The readme says that mermaid is recognized by github markdown, yet it includes the example as an image, preventing from seing how github renders it. Would be nice to use that feature directly.

Thanks !!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.