0

Lets assume you have a django website svn directory which is not under site-packages. Whenever i run:

mysyper_dir/whatever_module/manage.py runserver 0.0.0.0:8888

and then connect, I realize that my request are still handled by the python files in:

....../site-packages/whatever_module/

while I can see the prints of

mysyper_dir/whatever_module/setting.py

from my server console. is there a way to tell django that, every "non-framework" files it will ever need are in the "mysyper_dir/whatever_module" directory ?

user2346536
  • 1,464
  • 2
  • 21
  • 43

1 Answers1

1

Neither of these are Django specific (Python actually already handles this) but there's a couple of things you could do. You could set the environment variable PYTHONPATH, or you could add directories to sys.path. You can find more about where modules are located here.

If you are looking to have things just apply to Django, then adding to sys.path might be your best bet. You could try something weird like modifying manage.py and adding command line arguments after the #!/usr/bin/env python but that's uncharted territory for me.

Community
  • 1
  • 1
cwallenpoole
  • 79,954
  • 26
  • 128
  • 166
  • I'm not sure I understand, what seems totally counterintuitiev to me is that i'm running the manage.py runserver from one directory, but the request are handled by another directory ? how in the hell does the django server decides where is the server root ? is there some equivalent to the DocumentRoot/serverRoot of apache ? – user2346536 Mar 20 '14 at 14:16
  • Not sure why it is counter-intuitive. The Django source is in yet another directory, and the Python source is in a third. – cwallenpoole Mar 20 '14 at 14:19
  • The entire website is in a folder XXX, so whenever I run "XXX/manage.py runserver YYYYYY", I expect it to behave in the same way as if I had told apache the the serverroot was in the XXX folder. How does django server decides where to look for server files ? I haven't find any option in the doc – user2346536 Mar 20 '14 at 14:23
  • It doesn't "decide", not really. `manage.py` basically adds the current directory to `sys.path`. After that, Python just looks for modules in `sys.path`. – cwallenpoole Mar 20 '14 at 14:36
  • but when i print each element of my sys.path I can see XXX/ folder nut not the one from which python is running files... – user2346536 Mar 20 '14 at 14:38
  • Ok, actually you gave me the answer, removing the complete site-packages from my sys.path resolved the problem... – user2346536 Mar 20 '14 at 15:12