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???
So whats the way to go ?
I tend to use the simple
import sys
path = '/var/www/Django/'
if path not in sys.path:
sys.path.append(path)
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 use project.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's settings.py
. Does that make sense?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.