I pulled the trunk and 91 versions of Django into these folders:
/code/django_91src/
/code/django_95src/
I put this in my .bash_login:
export PYTHONPATH="/code/django91_src/django"
export PYTHONBIN="/code/django91_src/django/bin"
export
PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/opt/local/bin:/opt/local/sbin:$PYTHONBIN:$PATH"
I can get it to work if I put a symlink called 'django' in my
site-packages directory (below), but if it's not there, I can't 'import
django' from the Python shell:
/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages
So here's my question: can I make Django work if I don't have a symlink
in my site-packages directory? Creating the symlink makes me have to
choose which version (91 or 95) I want to point to, which seems to
defeat what I'm trying to do here.
Note: I didn't do a "python setup.py install" from either of the
versions in /code. That seemed to install the egg to site-packages.
I'm completely frustrated and don't know how to move forward. Any
advice is extremely appreciated!
When installing packages I can choose where to install them by
selecting the python interpreter.
/opt/local/bin/python setup.py install
installs packages to /opt/local/lib/python2.4/site-packages/ while
/usr/bin/python setup.py install
installs packages to
/Library/Frameworks/Python.framework/Libraries/python2.4/
site-packages/
I have used this to install Django 0.91 and Django current and by
calling
/opt/local/bin/python manage.py runserver
or
/usr/bin/python manage.py runserver
I can choose which one to use.
I use a couple bash aliases to quickly switch back and forth between
django versions. Note that DJANGO_SETTINGS_MODULE points to the
settings.py file that is somewhere on my python path. The following two
lines are in my ~/.bashrc file:
alias use91='export PYTHONPATH=/path/to/django91;export
DJANGO_SETTINGS_MODULE=foo.django.settings &&
/path/to/django91/django/bin/django-admin.py runserver'
alias usetrunk='export PYTHONPATH=/path/to/django_trunk;export
DJANGO_SETTINGS_MODULE=bar.settings &&
/path/to/django_trunk/django/bin/django-admin.py runserver'
When I need to test my Sargasso app, I start the development server from
a bash shell like this:
$ use91
To test my trunk app, I start the dev server like this:
$ usetrunk
I hope that helps.
Eric.
When using mod_python, it is possible to associate different parts of
the
URL namespace with different Python interpreter instances. Thus, you
should be able to run two different versions of Django under the one
web
server by hosting them under different URLs and then using the
directive
PythonInterpreter directive to separate them. For each instance, you
will
need to set the PythonPath directive to reference where the different
installations of Django are installed.
For example, something like:
<Location "/mysite1/">
PythonInterpreter django.mysite1
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonDebug On
PythonPath "['/path/to/project','/path/to/django1'] + sys.path"
</Location>
<Location "/mysite2/">
PythonInterpreter django.mysite2
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonDebug On
PythonPath "['/path/to/project','/path/to/django2'] + sys.path"
</Location>
Because they run in different Python interpreter instances, they
should not interfere with each other and doesn't matter that different
versions of same modules are used by each.
Graham
With a single installation of Python 2.4, I purposely did not symlink
or install Django in the site-packages folder.
I took out all references to PYTHONPATH and PYTHONBIN from my
.bash_login file.
I created a shell script to wrap manage.py:
#!/bin/bash
export PYTHONPATH=/core/django91_src
export DJANGO_SETTINGS_MODULE=ellington.settings
python manage.py runserver 3000
and with my 95 apps:
#!/bin/bash
export PYTHONPATH=/code/django95_src
export DJANGO_SETTINGS_MODULE=test.settings
python manage.py runserver 3000
As soon as I get it working with MOD_PYTHON, I'll document the same
here to help anyone who might get stuck where I did.