Django + Pydev/Eclipse + Google App Engine - 可能吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/523841/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Django + Pydev/Eclipse + Google App Engine - possible?
提问by
Has anyone been able to get Google App Engine/Django working in Pydev/Eclipse? I tried this but had difficulty getting Pydev to recognize all of the externally linked folders (django plugins) that I was referencing. I ended up copying all of those folders into the project en masse, rather than referencing them, resulting in a massively bloated project folder - it was really an unworkable solution that eventually made me give up the whole project. So, I'm wondering if anyone has tried this or has any idea what I might have been doing wrong. (Keep in mind this was my first attempt at using Pydev, Django, App Engine and Python!!)
有没有人能够让 Google App Engine/Django 在 Pydev/Eclipse 中工作?我试过了,但很难让 Pydev 识别我引用的所有外部链接文件夹(django 插件)。我最终将所有这些文件夹一起复制到项目中,而不是引用它们,导致项目文件夹大量膨胀 - 这确实是一个行不通的解决方案,最终让我放弃了整个项目。所以,我想知道是否有人尝试过这个或知道我可能做错了什么。(请记住,这是我第一次尝试使用 Pydev、Django、App Engine 和 Python!)
回答by Sam
I haven't personally set it up but i did see this tutorial on how to do it:
我没有亲自设置它,但我确实看到了有关如何操作的教程:
回答by Fabio Zadrozny
Pydev 1.4.6 (still only available in the nightly builds) has some special support to easy in the configuration. See: http://pydev.blogspot.com/2009/05/testing-on-pydev-146-google-app-engine.html
Pydev 1.4.6(仍然只在夜间构建中可用)在配置中有一些特殊的支持。请参阅:http: //pydev.blogspot.com/2009/05/testing-on-pydev-146-google-app-engine.html
回答by Jules
This question hasn't been replied to for some time and things have changed, so I thought I would provide and update.
这个问题已经有一段时间没有回复了,事情已经发生了变化,所以我想我会提供和更新。
PyDev now includes a Google App Engine configuration out of the box and you can debug and run GAE projects out of the box, this includes Django.
PyDev 现在包含一个开箱即用的 Google App Engine 配置,您可以开箱即用地调试和运行 GAE 项目,这包括 Django。
Just install GAE and the latest Eclipse/PyDev on your machine then create a GAE project and point PyDev at your versions of Python and Google App Engine.
只需在您的机器上安装 GAE 和最新的 Eclipse/PyDev,然后创建一个 GAE 项目并将 PyDev 指向您的 Python 和 Google App Engine 版本。
回答by shabdar
This tutorial shows how to configure Aptana (with PyDev installed) to be your coding and debugging platform for AppEngine. Similarly you can add Django libraries to Aptana too.
本教程展示了如何将 Aptana(安装了 PyDev)配置为您的 AppEngine 编码和调试平台。同样,您也可以将 Django 库添加到 Aptana。
http://www.alishabdar.com/2009/05/06/develop-google-appengine-with-aptana-studio/
http://www.alishabdar.com/2009/05/06/develop-google-appengine-with-aptana-studio/
回答by Casebash
I originally linked to this tutorial. Pydev now has Django support so this is probably less relevant. It may still be useful for figuring out how to make them all work together though. You could also try looking at this blog post.
我最初链接到本教程。Pydev 现在有 Django 支持,所以这可能不太相关。尽管如此,它可能仍然有助于弄清楚如何让它们一起工作。您也可以尝试查看此博客文章。
回答by jon
appengine 1.31
Django 1.1
pydev 1.5.4
OS Ubuntu 9.10
appengine 1.31
Django 1.1
pydev 1.5.4
操作系统 Ubuntu 9.10
eclipse .pydevproject file:
eclipse .pydevproject 文件:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse-pydev version="1.0"?>
<pydev_project>
<pydev_variables_property name="org.python.pydev.PROJECT_VARIABLE_SUBSTITUTION">
<key>GOOGLE_APP_ENGINE</key>
<value>/home/elvis/google_appengine</value>
</pydev_variables_property>
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
<path>/pythonleggo</path>
</pydev_pathproperty>
<pydev_pathproperty name="org.python.pydev.PROJECT_EXTERNAL_SOURCE_PATH">
<path>${GOOGLE_APP_ENGINE}</path>
<path>${GOOGLE_APP_ENGINE}/lib/webob</path>
<path>${GOOGLE_APP_ENGINE}/lib/yaml/lib</path>
</pydev_pathproperty>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.6</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
</pydev_project>
Files:
文件:
eclipse project folder
- app.yaml
- index.yaml
- init.py
- main.py
- manage.py
- .project
- .pydevproject
- settings.py (unable to load)
- urls.py
eclipse 项目文件夹
- app.yaml
- index.yaml
- init.py
- main.py
- manage.py
- .project
- .pydevproject
- settings.py(无法加载) - urls.py
main.py:
主要.py:
from google.appengine.dist import use_library
use_library('django', '1.1')
from django.conf import settings
settings.configure(
DEBUG=True,
TEMPLATE_DEBUG=True,
ROOT_URLCONF = 'urls',
PROJECT_NAME = 'pythonleggo',
SETTINGS_MODULE = '.settings',
ADMINS = ('elvis', '[email protected]'),
LANGUAGE_CODE = 'en-us',
SITE_ID = 1,
USE_I18N = True,
MEDIA_ROOT = '',
MEDIA_URL = '',
ADMIN_MEDIA_PREFIX = '/media/',
SECRET_KEY = 'shhh',
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source'),
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware'),
TEMPLATE_DIRS=('/home/jmurphy/workspace/pythonleggo/templates'),
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites')
)
#os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
import django.core.handlers.wsgi
from google.appengine.ext.webapp import util
def main():
# Run Django via WSGI.
application = django.core.handlers.wsgi.WSGIHandler()
util.run_wsgi_app(application)
if __name__ == ' __main__':
main()
eclipse run:
/usr/bin/python2.6 -u /home/elvis/google_appengine/dev_appserver.py
日食运行:
/usr/bin/python2.6 -u /home/elvis/google_appengine/dev_appserver.py
The PYTHONPATH that will be used is:
将使用的 PYTHONPATH 是:
/home/elvis/.eclipse/org.eclipse.platform_3.5.0_155965261/plugins/org.python.pydev_1.5.4.2010011921/PySrc/pydev_sitecustomize:/home/elvis/workspace/pythonleggo:/home/elvis/google_appengine:/home/elvis/google_appengine/lib/webob:/home/elvis/google_appengine/lib/yaml/lib:/usr/lib/pymodules/python2.6:/usr/lib/pymodules/python2.6/gtk-2.0:/usr/lib/python2.6:/usr/lib/python2.6/dist-packages:/usr/lib/python2.6/dist-packages/PIL:/usr/lib/python2.6/dist-packages/gst-0.10:/usr/lib/python2.6/dist-packages/gtk-2.0:/usr/lib/python2.6/lib-dynload:/usr/lib/python2.6/lib-old:/usr/lib/python2.6/lib-tk:/usr/lib/python2.6/plat-linux2:/usr/local/lib/python2.6/dist-packages
/home/elvis/.eclipse/org.eclipse.platform_3.5.0_155965261/plugins/org.python.pydev_1.5.4.2010011921/PySrc/pydev_sitecustomize:/home/elvis/workspace/pythonleggo:/home/elvis/google_appengine:/ home/elvis/google_appengine/lib/webob:/home/elvis/google_appengine/lib/yaml/lib:/usr/lib/pymodules/python2.6:/usr/lib/pymodules/python2.6/gtk-2.0:/ usr/lib/python2.6:/usr/lib/python2.6/dist-packages:/usr/lib/python2.6/dist-packages/PIL:/usr/lib/python2.6/dist-packages/gst -0.10:/usr/lib/python2.6/dist-packages/gtk-2.0:/usr/lib/python2.6/lib-dynload:/usr/lib/python2.6/lib-old:/usr/lib /python2.6/lib-tk:/usr/lib/python2.6/plat-linux2:/usr/local/lib/python2.6/dist-packages
I could not get the settings file to load using os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' . It appeared to be stripped from the environ that django received. I used settings.configure which appeared to work correctly. At this point I only have the default django page loading in appspot.
我无法使用 os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' 加载设置文件。它似乎从 Django 收到的环境中剥离出来。我使用了看起来可以正常工作的 settings.configure。在这一点上,我在 appspot 中只有默认的 django 页面加载。
回答by Filip Dupanovi?
I've just started with Python and the Google App Engine today. I think we both banged our heads against the same wall with external referencing.
我今天刚刚开始使用 Python 和 Google App Engine。我想我们都用外部引用把我们的头撞在同一堵墙上。
I've tried deploying the google-app-engine-djangoproject for my app. I've extracted everything and I have under my root the /appengine_django and /django folder.
我已经尝试为我的应用部署google-app-engine-django项目。我已经提取了所有内容,并且在我的根目录下有 /appengine_django 和 /django 文件夹。
I've added them as source folders, and I've added the /google_appengine/google folder as an external reference.
我已将它们添加为源文件夹,并将 /google_appengine/google 文件夹添加为外部参考。
Normally, this all made sense to me. Each contained the __ init __.py module. Still, when I tried to ctr+click on any of the import statements it couldn't resolve the path to the modules.
通常,这一切对我来说都是有意义的。每个都包含 __ init __.py 模块。尽管如此,当我尝试按 ctr+单击任何导入语句时,它无法解析模块的路径。
Strikingly, you do not import the immediate folder that contains an __ init __.py. To properly reference packages you import the parent folder that contains the package duh!That also means that, since I didn't want to use a /src folder, the actual project folder should be added as a source reference to get the /appengine_django and /django to be recognized as source folders.
引人注目的是,您没有导入包含 __ init __.py 的直接文件夹。要正确引用包,请导入包含包的父文件夹!这也意味着,由于我不想使用 /src 文件夹,因此应将实际项目文件夹添加为源引用,以使 /appengine_django 和 /django 被识别为源文件夹。
With that done, everything is running smoothly. I guess it's to show I have more reading up to do on Py.
完成后,一切都在顺利进行。我想这是为了表明我有更多关于 Py 的阅读要做。
回答by nelaaro
Here is an other tutorial that might help.
The eclispe version might be a bit old but it should get you
far enough to get a working project.
这是另一个可能有帮助的教程。
eclispe 版本可能有点旧,但它应该足以让您获得一个工作项目。
http://django-appengine.com/contents
http://django-appengine.com/contents
It has complete eclipse set up
http://django-appengine.com/post/37462709481/
http://www.mkyong.com/google-app-engine/google-app-engine-python-hello-world-example-using-eclipse/
它有完整的 Eclipse 设置
http://django-appengine.com/post/37462709481/
http://www.mkyong.com/google-app-engine/google-app-engine-python-hello-world-example-使用-eclipse/
It has complete gae set up
http://django-appengine.com/post/37615321945/
它已经完成了 gae 设置
http://django-appengine.com/post/37615321945/
It has complete django set up
http://django-appengine.com/post/37628665099/
它已经完成了 django 设置
http://django-appengine.com/post/37628665099/
And then explains how to combine those two projects
into one gae project.
http://django-appengine.com/post/37778427717/
然后解释如何将这两个项目合并为一个 gae 项目。
http://django-appengine.com/post/37778427717/
I hope this helps others who are just starting out
我希望这可以帮助其他刚开始的人