如何将自动生成的数据库模型图集成到管理文档界面中?
How can I integrate autogenerated database model diagrams into admin documentation interface?
我正在使用 graph_models
from django-extensions
从 Django 应用程序的数据库模型生成图表。我想将图表集成到管理界面的文档中 (django.contrib.admindocs
)。有没有办法整合图表(最好通过执行类似于python manage.py collectstatic
的流线型命令)?
我不明白你为什么不能。一种可能的方法是 create a management command that invokes the graph_models
command 带有参数,以便将文件输出到 STATIC_FILES
目录(它可能是其他静态文件设置)。
那你可以override whichever admin template you'd like to have the diagrams shown on. Perhaps including a link to the image of the diagram per table? I think that'd be django/contrib/admin/templates/admin/index.html.
您需要定义一些将在您的管理命令以及覆盖管理模板中使用的命名约定,以便正确呈现图像。
在您的部署过程中,调用 collectstatic
后,您将调用新的管理命令。
同样,这是一个选项。可能还有其他人。
我正在使用 graph_models
from django-extensions
从 Django 应用程序的数据库模型生成图表。我想将图表集成到管理界面的文档中 (django.contrib.admindocs
)。有没有办法整合图表(最好通过执行类似于python manage.py collectstatic
的流线型命令)?
我不明白你为什么不能。一种可能的方法是 create a management command that invokes the graph_models
command 带有参数,以便将文件输出到 STATIC_FILES
目录(它可能是其他静态文件设置)。
那你可以override whichever admin template you'd like to have the diagrams shown on. Perhaps including a link to the image of the diagram per table? I think that'd be django/contrib/admin/templates/admin/index.html.
您需要定义一些将在您的管理命令以及覆盖管理模板中使用的命名约定,以便正确呈现图像。
在您的部署过程中,调用 collectstatic
后,您将调用新的管理命令。
同样,这是一个选项。可能还有其他人。