I have to use Django 1.2 for just one of my projects.
I additionally curently have several projects running on Django 1.3 on a single server, and I have to have them running.
It is possible to method to just use 1.2 for any specific project?
Both sites operate on Apache via mod_wsgi.
Consider setting up Django in the virtualenv. This makes installing python modules, including Django, completely in addition to the relaxation from the system. By doing this, for those who have multiple virtualenvs, you could have as numerous versions of Django installed (one per env).
To utilize a virtualenv, you shold edit your
index.wsgi and add the next two lines before every other line that imports or references Django:
activate_this = '/path/to/env/bin/activate_this.py' execfile(activate_this, dict(__file__=activate_this))
This really is presuming that you're not using different version from the python interpreter itself, that is possible using virtualenv, but will make things a great deal more difficult.
Yes. Django is simply a regular Python module residing in your site-packages. Then when you
import django.something, the way in which Python decides which version to load is as simple as walking lower the Python path (
import sys; print sys.path) so as and searching for a directory known as django (with something.py or something/_init_.py inside). It loads the first it finds. Therefore the fastest technique is to change this Python path before beginning any project, which may be easily completed with an atmosphere variable named PYTHONPATH.
So for the Django 1.2 project, install Django 1.2 in site-packages/django-1.2 after which:
# run Django 1.2 for old app that I don't have time to update cd ~gaearon/src/old-django-project env PYTHONPATH=/Library/Python/2.6/site-packages/django-1.2 ./manage.py runserver
For those other (Django 1.3) projects, simply install Django normally, which causes it to be the default:
# all other projects use the system default Django 1.3 cd ~gaearon/src/current-django-project ./manage.py runserver
For production servers you will not use runserver, however the PYTHONPATH works wherever you invoke Python (i.e. flup, or manage.py runfcgi). If invoked from mod_python there's an Apache configuration directive to change the Python path (see mod_python documentation).
Or you might use virtualenv.
> mkvirtualenv django1.2 > cd django-1.2-dist-dir > python setup.py install > mkvirtualenv django1.3 > cd django-1.3-dist-dir > python setup.py install
Now both Django versions are installed in their own individual virtual conditions. To utilize a specific one do:
> workon django1.2
> workon django1.3