diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-08-15 12:25:21 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-08-15 12:25:21 +0000 |
| commit | 3835d8afec026e5dc3ad16c8b8e44071cb7ddc04 (patch) | |
| tree | 654e235c4ecd86b0c1fcfa34aa14751a64a0cad7 /docs/modpython.txt | |
| parent | ce151bb8e413a344627e29d3c1599ff06da672f2 (diff) | |
Fixed #4296 -- Added more explanation around the PythonPath directory setting. Based on contributions from a cast of thousands (Simon Greenhill, Paul Bissex, Graham Dumpleton, ...). Thanks, all.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5896 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/modpython.txt')
| -rw-r--r-- | docs/modpython.txt | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/docs/modpython.txt b/docs/modpython.txt index 676aab19ac..04f2110cf2 100644 --- a/docs/modpython.txt +++ b/docs/modpython.txt @@ -63,6 +63,30 @@ computer, you'll have to tell mod_python where your project can be found: **PythonPath "['/path/to/project'] + sys.path"** </Location> +The value you use for ``PythonPath`` should include the parent directories of +all the modules you are going to import in your application. It should also +include the parent directory of the ``DJANGO_SETTINGS_MODULE`` location. This +is exactly the same situation as setting the Python path for interactive +usage. Whenever you try to import something, Python will run through all the +directories in ``sys.path`` in turn, from first to last, and try to import +from each directory until one succeeds. + +An example might make this clearer. Suppose +you have some applications under ``/usr/local/django-apps/`` (for example, +``/usr/local/django-apps/weblog/`` and so forth), your settings file is at +``/var/www/mysite/settings.py`` and you have specified +``DJANGO_SETTINGS_MODULE`` as in the above example. In this case, you would +need to write your ``PythonPath`` directive as:: + + PythonPath "['/var/production/django-apps/', '/var/www'] + sys.path" + +With this path, ``import weblog`` and ``import mysite.settings`` will all +work. If you had ``import blogroll`` in your code somewhere and ``blogroll`` +lived under the ``weblog/`` directory, you would *also* need to add +``/var/production/django-apps/weblog/`` to your ``PythonPath``. Remember: the +**parent directories** of anything you import directly must be on the Python +path. + .. caution:: If you're using Windows, remember that the path will contain backslashes. |
