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?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Django __str__ returned non-string (type NoneType)
- Evil ctypes hack in python
As far as I know, it's just a matter of personal taste. I go with the directory which contains the project, but that's just my preference.
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 tosys.path
like so:where your files can be found.
Hope this helps