Specifying Alternate Settings with Django Jython WAR

January 24, 2011

I have a web application, written in Django that I want to deploy in Tomcat using Jython. I want to use seperate settings.py files for development and production.

In order to specify the settingslive.py file when building the WAR file, we can do this:

jython manage.py war --settings=settingslive

Unfortunately, this gives a runtime error in the browser:

modjy.modjy_exceptions.ApplicationException: Could not import settings 'settingslive' 
(Is it on sys.path? Does it have syntax errors?): No module named settingslive

This is something to do with the PYTHONPATH in the WAR file. We can get around the problem by using a fully qualified path for the settingslive.py file:

jython manage.py war --settings=ProjectFolder.settingslive