2010-11-20 96 views
1

我有一个文件结构如下所示:谷歌应用程序引擎(蟒蛇) - 导入失败

app.yaml 
something/ 
    __init__.py 
    models.py 
    test.py 

我已经URL设置为运行tests.pyapp.yaml

... 
- url: /test 
    script: something/test.py 

test.py进口models.py

当我尝试导航到http://myapp.appspot.com/test/时,出现以下错误:

Error: Server Error The server encountered an error and could not complete your request. If the problem persists, please report your problem and mention this error message and the > query that caused it

而且,当我检查仪表盘上的我看到下面的错误日志时:

<type 'exceptions.ImportError'>: No module named models 

如何正确导入该文件?

干杯,

皮特

+1

,如果你能告诉我们你的代码 - 我们可能会看到一些你可能会丢失。 – Glycerine 2010-11-20 23:48:50

+0

当您在SDK中运行应用程序时会发生什么? – SingleNegationElimination 2010-11-21 01:08:34

回答

0

尝试导入models这样的:

import something.models as models 
+0

这没有奏效 - 我仍然收到同样的错误。 – Peter 2010-11-20 23:46:56

+0

@Peter请编辑您的答案并添加更多详细信息:) – systempuntoout 2010-11-20 23:52:51

1

内test.py你可以在上面像写:

from something.models import * 

这将导入您的模型。 因为虽然纠正码 - 通配符“*”不是很大,你明确地导入您的使用模式:

from something.models import ModelName, OtherModel 

等。

1

test.py应该有imports models,不imports models.py

相关问题