Django 覆盖 startapp |启动项目命令
我需要创建一个具有不同文件和文件夹结构的 Django 项目。 特别是,在通过 startapp
命令创建新应用程序时,我需要添加 2 个文件夹:qqapp
和 qqproject
,每个文件夹都包含一些基本文件。
如何覆盖基本命令或添加自定义命令?
我当前的解决方案是编辑基本命令文件(更改默认文件夹的目录名称)django/core/management/commands/startapp| project.py,
但我认为这是个坏主意。
I need to create a Django Project with a different files and folder structure.
In particular I need to add 2 folders: qqapp
and qqproject
when creating a new app through the startapp
command, each containing some base files.
How can I override the base commands or add a custom one?
My current solution is editing the base commands files (changing dir name for default folders) django/core/management/commands/startapp|project.py,
but I think this is bad idea.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用项目模板 为此。
Use project templates for this.
有一个文档: https://docs.djangoproject.com /en/dev/howto/custom-management-commands/
there is a documentation for this: https://docs.djangoproject.com/en/dev/howto/custom-management-commands/