python - Accessing Django Modules from a Django subdirectory -


i'm setting documentation django project. documentation lives in folder called docs within project root:

  project-root/     doc/   app1/   app2/   app3/   urls/ 

the problem i'm writing extension documentation lives in doc/ folder. when generate documentation, run extension outside of context of django (just script). in extension, need access object in project's url's file.

but when try import project.urls, import error.

how can access project-root/urls when i'm running script in project-root/doc/extension.py isn't run through django?

you can setup django environment this:

import os, sys sys.path.append("/path/to/your_project/") os.environ["django_settings_module"] = "yourproject.settings" 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -