views:

25

answers:

1

I want to set up test and production versions of a Django app on separate apache name virtual hosts and wanted to know the best way to do this.

Here's what I've done, and it seems to work ok, but I'm wondering if there's a better way.

<VirtualHost *>
    ServerName test.foo.bar

    <Location "/app/">
        SetHandler python-program
        PythonPath "['/home/jdm/django-apps/xyz/test/'] + sys.path"
        PythonHandler django.core.handlers.modpython
        SetEnv DJANGO_SETTINGS_MODULE settings
    PythonOption django.root /app
        PythonDebug On
        PythonInterpreter test
    </Location>

</VirtualHost>


<VirtualHost *>
    ServerName live.foo.bar

    <Location "/app/">
        SetHandler python-program
        PythonHandler django.core.handlers.modpython
        PythonPath "['/home/jdm/django-apps/xyz/live/'] + sys.path"
        SetEnv DJANGO_SETTINGS_MODULE settings
        PythonOption django.root /app
        PythonDebug On
        PythonInterpreter live
    </Location>

</VirtualHost>

The apps live in /home/jdm/django-apps/xyz/live/ and /home/jdm/django-apps/xyz/test/. The apps are at http://live.foo.bar/app/ and http://test.foo.bar/app/

A: 

I think virtualenv is what you need.

Daniel Roseman