Google 应用部署上的 django-nonrel 500 服务器错误

发布于 2024-09-11 20:43:29 字数 659 浏览 6 评论 0原文

我是一个新手,在 Google App Engine 上使用 Django-nonrel 时遇到问题。

我创建了一个名为“helloapp”的新应用程序。

1)我在views.py中创建了一个名为hello world的视图:

从 django.http 导入 HttpResponse

def 你好(请求):
     返回 HttpResponse("Hello world")

2)然后我使用以下方法在 urls.py 中链接到它:

从 django.conf.urls.defaults 导入 *
从 helloapp.views 导入 hello

urlpatterns = 模式('',
     (r'^你好/$',你好),

这在本地工作正常,但在现场我收到 500 服务器错误。

在 GAE 日志中,我看到出现导入错误

ImportError: No module named helloapp.views

这很令人困惑,因为如上所述,这在本地工作得很好。

帮助。

I am a newbie with a problem working with Django-nonrel on Google App Engine.

I created a new app called "helloapp".

1) I have created a view in views.py called hello world:

from django.http import HttpResponse

def hello(request):
     return HttpResponse("Hello world")

2) I have then linked to it in the urls.py using:

from django.conf.urls.defaults import *
from helloapp.views import hello

urlpatterns = patterns('',
     (r'^hello/$',hello),
)

This works fine locally, but on live I am getting 500 Server error.

In the GAE logs I see that I am getting an import error

ImportError: No module named helloapp.views

This is confusing since, as mentioned, this works fine locally.

Help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如梦初醒的夏天 2024-09-18 20:43:29

也许试试这个:

from views import hello

本地的views.py 位于helloapp 目录中。但是,当它上传到应用程序引擎时,它会被放置到具有如下版本号的目录中,其中 helloapp.views 不存在:

/base/data/home/apps/helloapp/1.23456789/views.py

Maybe try this:

from views import hello

Locally your views.py is in a helloapp directory. But when it gets uploaded onto app engine it is placed into a directory with a version number like this, where helloapp.views does not exist:

/base/data/home/apps/helloapp/1.23456789/views.py

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文