2010-11-20 178 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

相關問題