Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
  • Loading branch information...
commit 3835d8afec026e5dc3ad16c8b8e44071cb7ddc04 1 parent ce151bb
Malcolm Tredinnick authored August 15, 2007

Showing 1 changed file with 24 additions and 0 deletions. Show diff stats Hide diff stats

  1. 24  docs/modpython.txt
24  docs/modpython.txt
@@ -63,6 +63,30 @@ computer, you'll have to tell mod_python where your project can be found:
63 63
         **PythonPath "['/path/to/project'] + sys.path"**
64 64
     </Location>
65 65
 
  66
+The value you use for ``PythonPath`` should include the parent directories of
  67
+all the modules you are going to import in your application. It should also
  68
+include the parent directory of the ``DJANGO_SETTINGS_MODULE`` location. This
  69
+is exactly the same situation as setting the Python path for interactive
  70
+usage. Whenever you try to import something, Python will run through all the
  71
+directories in ``sys.path`` in turn, from first to last, and try to import
  72
+from each directory until one succeeds.
  73
+
  74
+An example might make this clearer. Suppose
  75
+you have some applications under ``/usr/local/django-apps/`` (for example,
  76
+``/usr/local/django-apps/weblog/`` and so forth), your settings file is at
  77
+``/var/www/mysite/settings.py`` and you have specified
  78
+``DJANGO_SETTINGS_MODULE`` as in the above example. In this case, you would
  79
+need to write your ``PythonPath`` directive as::
  80
+
  81
+    PythonPath "['/var/production/django-apps/', '/var/www'] + sys.path"
  82
+
  83
+With this path, ``import weblog`` and ``import mysite.settings`` will all
  84
+work. If you had ``import blogroll`` in your code somewhere and ``blogroll``
  85
+lived under the ``weblog/`` directory, you would *also* need to add
  86
+``/var/production/django-apps/weblog/`` to your ``PythonPath``. Remember: the
  87
+**parent directories** of anything you import directly must be on the Python
  88
+path.
  89
+
66 90
 .. caution::
67 91
 
68 92
     If you're using Windows, remember that the path will contain backslashes.

0 notes on commit 3835d8a

Please sign in to comment.
Something went wrong with that request. Please try again.