Django 1.1 on the Google App Engine SDK
If you’ve used Django 1.1 App Engine, or are trying to, then you’ve probably read the instructions on how replace Django 0.96 with 1.1. That all fine an dandy in a production environment, but what about local development? Perhaps you’ve seen the following error message?
UnacceptableVersionError: django 1.1 was requested, but 1.2.1.final.0 is already in use
Me too. After mucking around a bit, I’ve figured out an acceptable workaround:
Then, modify your
main.py from this:
import os, sys,logging os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' from google.appengine.dist import use_library use_library('django', '1.1')
To look like this:
import os, sys,logging os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' if os.environ.get('SERVER_SOFTWARE','').startswith('Devel'): sys.path.insert(0, "/your/local/path/to/Django-1.1.1/") from google.appengine.dist import use_library use_library('django', '1.1')
Essentially, you’re telling App Engine that, when it’s in the Development environment (running on your local computer), it should prepend Django 1.1.1 to the system path. Then, a few lines down, when the App Engine SDK looks for Django, it will see that version first.