Google App Engine和Django支持

时间:2021-02-05 20:23:25

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.

我正在尝试按照此文档将我的Django应用程序部署到Google App Engine(GAE)。我创建并配置了一个Google Cloud SQL实例,如该文档中所述。我使用PyCharm作为开发环境,并创建了一个支持Django的GAE项目。

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:

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

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

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.

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

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?

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

EDIT: 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.

编辑:更确切地说,GAE本地服务器启动很好但在我执行syncdb任务来更新我的数据库时抛出所提到的堆栈跟踪。

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:

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

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

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

编辑3:尝试使用本教程部署现有的Django应用程序时遇到了问题。看到这个单独的问题。

1 个解决方案

#1


11  

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/

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

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

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

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

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

我写了一篇关于将Django与GAE和Google Cloud SQL一起使用的教程。那里可能还有一些相关的信息。

#1


11  

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/

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

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

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

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

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

我写了一篇关于将Django与GAE和Google Cloud SQL一起使用的教程。那里可能还有一些相关的信息。