Skip to content

Instantly share code, notes, and snippets.

@gregelin
Created December 3, 2017 12:59
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gregelin/e2451b387170969cd77df090e5a3170e to your computer and use it in GitHub Desktop.
Save gregelin/e2451b387170969cd77df090e5a3170e to your computer and use it in GitHub Desktop.
Generating ERD for django projects
# Install django-extensions
# http://django-extensions.readthedocs.io/en/latest/installation_instructions.html
pip3 install django-extensions

# Add django-extensions INSTALLED_APPS in siteapp > settings.py
# INSTALLED_APPS = (
#    ...
#    'django_extensions',
# )

# You may need to install pyparsing
pip3 install pyparsing

# examples:
python3 manage.py graph_models -a -g -o my_project_visualized.png
python3 manage.py graph_models -a -o my_project.png
python3 manage.py graph_models -a > my_project.dot
# for a single django app:
python3 manage.py graph_models app1 -o my_project_app1.png
@rbabaee2014
Copy link

pygraphviz and pydotplus is also needed apparently .

@DadhichVipin
Copy link

showing error:
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.

@nick-solly
Copy link

Another option is this little project I put together: https://github.com/nick-solly/django-diagram

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment