see test_query.ipynb


In [2]:
import os
import sys
import subprocess
ROOT_PATH=os.getcwd()
manage = os.path.join(ROOT_PATH , "manage.py")
print subprocess.check_output([sys.executable, manage, "makemigrations","--noinput"])
print subprocess.check_output([sys.executable, manage, "migrate","--noinput"])


No changes detected

Operations to perform:
  Apply all migrations: admin, app, auth, contenttypes, sessions
Running migrations:
  No migrations to apply.


In [3]:
import pydot
import time
timestr = time.strftime("%y%m%d_%H%M%S")

dotstr=subprocess.check_output([sys.executable, manage, "graph_models", "-a"])
#with  open("models.dot","w") as f:
#    f.write(dotstr)
#(graph,) = pydot.graph_from_dot_file('models.dot')
(graph,) = pydot.graph_from_dot_data(dotstr)
graph.write_png(timestr + '.png')
#open the png


Out[3]:
True

In [4]:
from IPython.display import display, Markdown, Latex
md='''<img src="%s",width=60,height=60>'''%(timestr + '.png')
display(Markdown(md))


<img src="161115_134414.png",width=60,height=60>


In [ ]:


In [ ]:


In [ ]: