tags:

views:

203

answers:

3

I'm configuring autocompletion for python and django in vim. One of the problems is that I need to set an environment variable DJANGO_SETTINGS_MODULE=myapp.settings. The django tutorial states that

The value of DJANGO_SETTINGS_MODULE should be in Python path syntax, e.g. mysite.settings. Note that the settings module should be on the Python import search path.

http://docs.djangoproject.com/en/dev/topics/settings/

But if your app isn't in the import search path, how do you make it so that it is?

+2  A: 

Try appending the path to sys.path at runtime.

import sys
sys.path.append('/path/to/myapp')
rubayeet
+2  A: 

Add this in your .bashrc or .bash_profile

export PATH=$PATH:/path/to/django/bin

export PYTHONPATH=$PYTHONPATH:/path/to/myapp

olarva
+1  A: 

Three choices.

  1. Set PYTHONPATH environment variable to include your application's directory. Be sure it has an __init__.py file.

  2. Create a .pth file in site-packages to point to your application's directory.

  3. Install your application in site-packages.

These are the three ways of "installing" a Python module. Read about the site module for more information.

S.Lott