Django: What is `sys.path`?

When developing a Django application, what should sys.path contain? The directory that contains the project, or the project directory, or both?

+4
source share
2 answers

sys.path should and will have a project directory. Depending on your setup, it may also contain a directory containing the project.

However, if the motivation for this question is to make sure some files can be found, then you should notice that sys.path like a normal list and can be added. Therefore, you can add a new location in sys.path like this:

 sys.path.append('/home/USER/some/directory/') 

where your files can be found.

Hope this helps

+3
source

As far as I know, this is just a matter of personal taste. I go with the directory that contains the project, but these are just my preferences.

0
source

All Articles