10
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Django で Models.py の ER図をPDF化

Last updated at Posted at 2019-05-19

概要

django-extensions の graph_models を使って Models.py から ER 図を PDF形式 で出力

環境

  • Windows 10 Latest
  • Powershell Latest
  • python 3 Latest
  • Miniconda 3 Latest
  • django 2.2

前準備

condaでPythonパッケージをインストール

AnacondaOnPoweshell
conda install pygraphviz
conda install pydotplus
conda install django-extensions

Windows Terminal に Anaconda Powershell Prompt を追加することができるので、そこでこのコマンドを実行しています。

Django プロジェクトの settings.py で INSTALLED_APPS に追加

settings.py

INSTALLED_APPS = [
    # INSTALLED_APPS

    'django_extensions',
]

コマンド

例1

AnacondaOnPoweshell
python manage.py graph_models -a -g -o graph-model.pdf

例2

AnacondaOnPoweshell
python manage.py graph_models auth -I User,Group

例3

AnacondaOnPoweshell
python manage.py graph_models auth -g -o graph-model-auth.pdf

Windows Terminal に Anaconda Powershell Prompt を追加することができるので、そこでこのコマンドを実行しています。

出力形式

  • png, jpg
  • svg
  • pdf
  • etc

参考

Excelsior!

10
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?