Django 项目和应用程序
我是 django 新手,试图将我的项目和应用程序放在桌面上的目录中。我需要将这些目录添加到 python 路径中,以便它知道它们位于哪里并且可以彼此交互。我该怎么做最好的?我发现了几种可能有缺点的方法???
- 通过 shell, import sys, sys.path.append('/my/dir') 不是永久的?
- 通过 sitecustomize.py,这是永久性的,但在我的 python IDE 中,模块似乎被加载了多次? 在框架(macosx)中运行
- 因为我的Python通过命令行导出PYTHONPATH:$等
所以该怎么走?
i am a django newbie, and trying to get my projects and apps in a directory on my desktop.. I need to add these directories to the python path so it knows where they live and can interact with eachother.. how can I do this best? I found several ways which might have downsides???
- through shell, import sys, sys.path.append('/my/dir') isn't permanent?
- through sitecustomize.py, this is permanent but in my python IDE it seems modules get loaded multiple times? because my python in running in a framework (macosx)
- through commandline export PYTHONPATH:$ etc etc
So whats the way to go ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我倾向于使用简单的
In WSGI 脚本来“增强”我的应用程序。我还有一个自定义管理命令,它在调用 shell 之前执行此操作。在此之前,我只是将上面的内容转储到
settings.py
。/var/www/Django
是我所有项目所属的位置 - 因此,如果我指的是一个项目,我总是使用project.app
。一旦我创建了一个可重复使用的便携式应用程序,它就会毕业并存在于/var/www/Django
本身中,并通过其他项目的settings.py
包含进来。这有道理吗?I tend to use the simple
In my WSGI scripts which "power" my application. I also have a custom management command that does exactly this before calling shell. Previously to that, I simply dumped the above in
settings.py
./var/www/Django
is where all my projects belong - thus if I'm referring to a project I always useproject.app
. Once I've created a portable app for re-use, it graduates and lives in/var/www/Django
itself and gets included via other project'ssettings.py
. Does that make sense?