Reputation: 16563
I have a Python 2.7 GAE app that uses Django 1.2. Everything generally works fine.
I'm trying to use remote_api_shell.py
, but when I import my models.py
, I get this error:
$ PYTHONPATH=.; remote_api_shell.py APP
App Engine remote_api shell
Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
The db, users, urlfetch, and memcache modules are imported.
s~APP> import models
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Users/.../models.py", line 8, in <module>
from django.core.validators import email_re
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/django_0_96/django/core/validators.py", line 13, in <module>
from django.utils.translation import gettext, gettext_lazy, ngettext
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/django_0_96/django/utils/translation/__init__.py", line 3, in <module>
if settings.USE_I18N:
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/django_0_96/django/conf/__init__.py", line 28, in __getattr__
self._import_settings()
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/django_0_96/django/conf/__init__.py", line 53, in _import_settings
raise EnvironmentError, "Environment variable %s is undefined." % ENVIRONMENT_VARIABLE
EnvironmentError: Environment variable DJANGO_SETTINGS_MODULE is undefined.
I don't know why it is using Django 0.96 here. Especially since I think Python 2.7 supports only Django 1.2. Here are the relevant parts of my app.yaml
:
application: APP
version: prod
runtime: python27
api_version: 1
threadsafe: true
[...]
libraries:
- name: django
version: "1.2"
If I comment out the from django.core.validators import email_re
line then the import succeeds.
Any idea if I am doing something wrong or if this is this a GAE bug?
Upvotes: 1
Views: 417
Reputation: 590
FYI this no longer works because
use_library('django', '1.5')
now throws this error:
ValueError: 1.5 is not a supported version for django; supported versions are ['0.96', '1.0', '1.1', '1.2', '1.3']
Hopefully this is a temporary problem, but my solution was to delete (rename):
C:\Program Files (x86)\Google\google_appengine\lib\django-0.96
to something else, then the proper version of django loads w/o any other problems.
Upvotes: 0
Reputation: 1941
I had the same issue, and I solved it by running these two lines once I open the remote API session:
from google.appengine.dist import use_library
use_library('django', '1.3')
Though, clearly, it's a hack. Star this issue to encourage the app engine team to fix it:
https://code.google.com/p/googleappengine/issues/detail?id=8716
Upvotes: 3
Reputation: 12138
try typing this:
import django
django.VERSION
To check the django version! I am guessing that the python console that u are running has the old version of django!
Upvotes: 1