Django 覆盖 startapp |启动项目命令

发布于 2024-12-10 12:14:11 字数 312 浏览 1 评论 0原文

我需要创建一个具有不同文件和文件夹结构的 Django 项目。 特别是,在通过 startapp 命令创建新应用程序时,我需要添加 2 个文件夹:qqappqqproject,每个文件夹都包含一些基本文件。

如何覆盖基本命令或添加自定义命令?

我当前的解决方案是编辑基本命令文件(更改默认文件夹的目录名称)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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

家住魔仙堡 2024-12-17 12:14:11

使用项目模板 为此。

django-admin.py startproject --template=/path/to/my_project_template myproject

Use project templates for this.

django-admin.py startproject --template=/path/to/my_project_template myproject
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文