谷歌app引擎上django的路径

时间:2010-12-20 13:52:43

标签: google-app-engine django-nonrel

我完全不明白这个错误。我使用django-nonrel,通过manage.py将其上传到我的应用程序。 有时我有这个:

<type 'exceptions.AttributeError'>: 'Settings' object has no attribute 'DATABASE_ROUTERS'
Traceback (most recent call last):
File "/base/data/home/apps/appid/3.347077242893060339/execute.py", line 2, in <module>
  from djapp import queue_controller
File "/base/data/home/apps/appid/3.347077242893060339/djapp/queue_controller.py", line 5, in <module>
  from djapp.models import Operation
File "/base/data/home/apps/appid/3.347077242893060339/djapp/models.py", line 3, in <module>
  from django.db import models
File "/base/data/home/apps/appid/3.347077242893060339/django/db/__init__.py", line 66, in <module>
  router = ConnectionRouter(settings.DATABASE_ROUTERS)
File "/base/python_runtime/python_lib/versions/third_party/django-0.96/django/conf/__init__.py", line 32, in __getattr__
  return getattr(self._target, name)

<type 'exceptions.ImportError'>: No module named files.uploadhandler  
Traceback (most recent call last):
File "/base/data/home/apps/appid/3.347067228745038183/djangoappengine/main/main.py", line 28, in <module>
  from django.core.handlers.wsgi import WSGIHandler
File "/base/python_runtime/python_lib/versions/third_party/django-0.96/django/core/handlers/wsgi.py", line 1, in <module>
  from django.core.handlers.base import BaseHandler
File "/base/python_runtime/python_lib/versions/third_party/django-0.96/django/core/handlers/base.py", line 3, in <module>
  from django import http
File "/base/data/home/apps/appid/3.347067228745038183/django/http/__init__.py", line 28, in <module>
  from django.http.multipartparser import MultiPartParser
File "/base/data/home/apps/appid/3.347067228745038183/django/http/multipartparser.py", line 14, in <module>
  from django.core.files.uploadhandler import StopUpload, SkipFile, StopFutureHandlers

路径有什么问题?为什么会这样?首先路径为“/base/data/home/apps/app-id/3.347046818251769742/django/”,然后是“/base/python_runtime/python_lib/versions/third_party/django-0.96/django/".
以及如何避免这个错误?

我已经检查过sys.path,上传了几次新的django,删除了所有不必要的文件,我迷路了:(

sys.path = ['/base/data/home/apps/appid/3.347077364008022180', 
'/base/data/home/apps/appid/3.347077364008022180/djangoappengine/lib', 
'/base/python_runtime/python_dist/lib/python25.zip', 
'/base/python_runtime/python_dist/lib/python2.5/', 
'/base/python_runtime/python_dist/lib/python2.5/plat-linux2', 
'/base/python_runtime/python_dist/lib/python2.5/lib-tk',
'/base/python_runtime/python_dist/lib/python2.5/lib-dynload',
'/base/python_runtime/python_lib/versions/1',
'/base/data/home/apps/appid/3.347077364008022180/']

1 个答案:

答案 0 :(得分:0)

我猜db/__init__.pyfrom django.conf import Settings之类的事情,无论出于何种原因,它有时会被赋予系统的Django版本而不是你自己的版本。

您可以尝试将其更改为使用相对导入,例如from ..conf import Settings,这应该意味着它使用相同包中的版本。这适用于Python 2.5,这是Appengine使用的。