如何在Django中创建子应用程序? [英] How do I create sub-applications in Django?
问题描述
理想情况下,我最终会得到如下结构:
project /
app /
subapp1 /
subapp2 /
我尝试过 manage.py startapp应用程序.subapp1
和 manage.py startapp app / subapp1
但这告诉我 /
和。
是应用程序名称的无效字符。
我已经尝试改成app目录,并运行 ../ manage.py subapp1
,但这使supapp1在顶层。注意,我不想试图直接制作一个独立的应用程序。我试图从一个项目中做所有这些。
你仍然可以这样做:
cd app
django-admin startapp subapp1
这将工作(创建应用程序基本结构),但是 app
和 subapp1
将仍然被认为是两个不相关的应用程序,您必须将它们都添加到设置中的 INSTALLED_APPS
。
<这是否回答你的问题?否则,你应该更多地了解你正在努力做什么。
I'm a Django newbie, but fairly experienced at programming. I have a set of related applications that I'd like to group into a sub-application but can not figure out how to get manage.py to do this for me.
Ideally I'll end up with a structure like:
project/
app/
subapp1/
subapp2/
I've tried manage.py startapp app.subapp1
and manage.py startapp app/subapp1
but this tells me that /
and .
are invalid characters for app names.
I've tried changing into the app directory and running ../manage.py subapp1
but that makes supapp1 at the top level. NOTE, I'm not trying to directly make a stand-alone application. I'm trying to do all this from within a project.
You can still do this :
cd app
django-admin startapp subapp1
This will work (create the application basic structure), however app
and subapp1
will still be considered as two unrelated applications in the sense that you have to add both of them to INSTALLED_APPS
in your settings.
Does this answer your question ? Otherwise you should tell more about what you are trying to do.
这篇关于如何在Django中创建子应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!