Django:应该是什么`sys.path`? [英] Django: What is `sys.path` supposed to be?
问题描述
在开发Django应用程序时,应该包含什么是 sys.path
?包含项目的目录,或项目的目录,还是两者?
sys。路径
应该并且将具有项目的目录。根据您的设置,它还可能包含包含项目的目录。但是,如果这个问题背后的动机是确保可以找到某些文件,那么您应该注意到 sys.path
就像一个正常的列表,可以附加到。因此,您可以添加新位置到 sys.path
,如下所示:
sys.path.append('/ home / USER / some / directory /')
其中您可以找到您的文件。
希望这有助于
When developing a Django application, what is sys.path
supposed to contain? The directory which contains the project, or the directory of the project, or both?
sys.path
should and will have the directory of the project. Depending on what your setup is, it may also contain the directory which contains the project.
However, if the motivation behind this question is to ensure that certain files can be found, then you should note that sys.path
is just like a normal list and can be appended to. Therefore, you can add a new location to sys.path
like so:
sys.path.append('/home/USER/some/directory/')
where your files can be found.
Hope this helps
这篇关于Django:应该是什么`sys.path`?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!