Reputation: 1216
I have dev and production systems.
My production system is different from my dev system in that that it adds one directory to the beginning path.
for eg. on dev system:
main->module1->module2
becomes on production:
project_name->main->module1->module2.
Because of that I have to change all my imports to accommodate for this change.
I wanted to make settings file in the main folder and include it in every file and call exec("import %s.modulexxx" % path).
But the problem is how to access settings file (because I also need to know my directory path).
Is there a way to include some file below, for eg. :
if it is main->module1->module2 , in module2 I could include ../../settings.py so if it changes to project_name->main->module1->module2 it would still work because it would still be 2 level below.
Any help?
Upvotes: 0
Views: 61
Reputation: 526583
Why not just modify sys.path
to include the directory one level down? Then the same imports will work in both places.
Upvotes: 4