Google App Engine 和 Django 支持 [英] Google App Engine and Django support

查看:23
本文介绍了Google App Engine 和 Django 支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试按照 本文档.如该文档中所述,我创建并配置了一个 Google Cloud SQL 实例.我使用 PyCharm 作为开发环境,并创建了一个支持 Django 的 GAE 项目.

I'm trying to deploy my Django app to Google App Engine (GAE) as per this document. I created and configured a Google Cloud SQL instance, as described in that document. I use PyCharm as development environment and created a GAE project with Django support.

我将本地服务器配置为指向 GAE 服务器.当我尝试在 PyCharm 中启动 GAE 本地服务器时,它会在 SETTINGS.PY 中配置不正确的数据库上引发异常:

I configured a local server to point to the GAE server. When I try to launch the GAE local server in PyCharm, it's raising exceptions on an improperly configured database in SETTINGS.PY:

google.appengine.ext.django.backends.rdbms' isn't an available database backend

我可以从堆栈跟踪中看到本地服务器正在使用 /Library/Python/2.7/site-packages 中的 Django 版本,而我认为它应该使用 /中的那个usr/local/google_appengine/lib.

I can see from the stack trace that the local server is using the Django version in /Library/Python/2.7/site-packages while I presume it should use the one in /usr/local/google_appengine/lib.

如果我还有其他 Django 项目也应该使用 /Library/Python/2.7/site-packages 中的 Django 版本,那么解决这个问题的最佳方法是什么?如果我修改我的 PYTHONPATH 以包含 Django 的 GAE 版本,我的所有项目不会引用该版本的 Django 吗?

What would be the best way to solve this given that I have other Django projects as well that should use the Django version in /Library/Python/2.7/site-packages? If I modify my PYTHONPATH to include the GAE version of Django, would not all my projects be referencing that version of Django?

更准确地说,GAE 本地服务器启动得很好,但是当我执行 syncdb 任务来更新我的数据库时会抛出上述堆栈跟踪.

To be more precise, the GAE local server starts just fine but throws the mentioned stack trace when I do a syncdb task to update my database.

编辑 2: 在 Python Interpreter 下的 PyCharm 设置中,我发现可以修改路径并添加与 GAE SDK 一起分发的 Django 1.4 版本.当我启动 GAE 开发服务器时,我实际上可以看到它使用 GAE SDK 中的 Django 版本,但它仍然在数据库定义上崩溃:

EDIT 2: In PyCharm Settings under Python Interpreter, I found the possibility to modify paths and added the Django 1.4 version as distributed with GAE SDK. When I start the GAE development server, I can actually see it uses the Django version from the GAE SDK but it still crashes on the database definitions:

Error was: No module named google.appengine.ext.django.backends.rdbms.base

编辑 3:我在尝试使用本教程部署现有 Django 应用程序时遇到了问题.请参阅这个单独的问题.

EDIT 3: I ran into problems when trying to deploy an existing Django app using the tutorial. See this separate question.

推荐答案

看起来 PyCharms 调用 syncdb 使用了错误的 Django 安装.google.appengine.ext.django.backends.rdbms 不是官方 Django 发行版的一部分,但它是 GAEs django 的一部分.我的 GAE django 位于 /usr/local/google_appengine/lib/

Looks like PyCharms call of syncdb is using the wrong Django installation. google.appengine.ext.django.backends.rdbms is not part of the official Django distribution, but it is part of GAEs django. My GAE django is in /usr/local/google_appengine/lib/

如果您使用的是 linux/OS X,您可以将其添加到您的 .bashrc/.bash_profile 并让 syncdb 使用它:

If you're on linux/OS X you could add this to your .bashrc/.bash_profile and make syncdb use this:

export GAE="/usr/local/google_appengine"
export PYTHONPATH="$PYTHONPATH:$GAE:$GAE/lib/django_1_4"
export PATH=${PATH}:$GAE/lib/django_1_4/django/bin/
export PATH=${PATH}:/usr/local/mysql/bin

我写了一个教程关于将 Django 与 GAE 和 Google Cloud SQL 结合使用.那里可能还有一些相关信息.

I wrote a tutorial about using Django with GAE and Google Cloud SQL. There might be some relevant infos there as well.

这篇关于Google App Engine 和 Django 支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆