Google App Engine和Django支持 [英] Google App Engine and Django support
问题描述
我正在尝试根据 Django 应用部署到 Google App Engine
(GAE) =https://developers.google.com/appengine/docs/python/cloud-sql/django =nofollow noreferrer>本文档。我创建并配置了一个 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
以包含GAE版本的Django,我的所有项目都不是引用该版本的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?
编辑:更精确地说,当我执行 syncdb
任务时,GAE本地服务器启动很好,但会抛出上述的堆栈跟踪更新我的数据库。
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解释器中的PyCharm设置中,我发现修改路径并添加了Django 1.4版本的可能性与GAE SDK分发。当我启动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发行版的一部分,但它是GAE 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
我写了一个关于在GAE和Google Cloud SQL中使用Django的教程。也可能有一些相关的信息。
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屋!