Django + Pydev/Eclipse +谷歌应用程序引擎——可能吗?

时间:2021-05-02 19:18:54

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!!)

有人能在Pydev/Eclipse中获得谷歌应用引擎/Django吗?我尝试过这种方法,但是很难让Pydev识别我引用的所有外部链接文件夹(django插件)。我最终将所有这些文件夹全部复制到项目中,而不是引用它们,导致项目文件夹严重膨胀——这确实是一个无法使用的解决方案,最终导致我放弃了整个项目。所以,我想知道是否有人尝试过或者知道我做错了什么。(请记住,这是我第一次尝试使用Pydev、Django、App Engine和Python!)

8 个解决方案

#1


9  

I haven't personally set it up but i did see this tutorial on how to do it:

我还没有亲自设置它,但是我确实看到了关于如何实现它的教程:

http://code.google.com/appengine/articles/eclipse.html

http://code.google.com/appengine/articles/eclipse.html

#2


5  

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——在谷歌——应用程序——engine.html pydev中- 146

#3


3  

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/

#4


3  

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现在包含了一个现成的谷歌应用程序引擎配置,您可以直接调试和运行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,然后在您的Python和谷歌应用程序引擎版本中创建GAE项目并将PyDev指向您的版本。

#5


2  

appengine 1.31
Django 1.1
pydev 1.5.4
OS Ubuntu 9.10

appengine 1.31 Django 1.1 pydev 1.5.4 OS 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 -主要。py -管理。py - .project - .pydevproject -设置。py(无法装载)- urls.py


main.py:

main.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', 'elvis@gmail.com'),
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

eclipse运行:/usr/bin/python2.6 -u /home/elvis/google_appengine/dev_appserver.py

The PYTHONPATH that will be used is:

将使用的python路径是:

/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 /插件/ org.python.pydev_1.5.4.2010011921 / PySrc / pydev_sitecustomize:/ home /猫王/ workspace / pythonleggo:/ home /猫王/ google_appengine:/ home /猫王/ google_appengine / lib / webob:/ home /猫王/ 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 /公益诉讼:/ 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 /地方/ 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加载设置文件。环境[' DJANGO_SETTINGS_MODULE ']=“设置”。它似乎被从django接收到的环境中删除了。我使用的设置。配置哪个看起来工作正确。此时,我只在appspot中有默认的django页面加载。

#6


2  

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,所以这可能不太相关。不过,这对于弄清楚如何让它们一起工作可能仍然有用。你也可以看看这个博客。

#7


1  

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和谷歌应用程序引擎。我想我们都是用外参照的方式把头撞在了同一面墙上。

I've tried deploying the google-app-engine-django project 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/谷歌文件夹添加为外部引用。

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.

通常,这对我来说都是有意义的。每个都包含了初始__。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的直接文件夹。要正确引用包,您需要导入包含包duh的父文件夹!这也意味着,因为我不想使用/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.

做完这些,一切都进展顺利。我想这是为了表明我还有更多的阅读要做。

#8


0  

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- python- world-example-us -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

我希望这能帮助那些刚刚起步的人

#1


9  

I haven't personally set it up but i did see this tutorial on how to do it:

我还没有亲自设置它,但是我确实看到了关于如何实现它的教程:

http://code.google.com/appengine/articles/eclipse.html

http://code.google.com/appengine/articles/eclipse.html

#2


5  

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——在谷歌——应用程序——engine.html pydev中- 146

#3


3  

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/

#4


3  

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现在包含了一个现成的谷歌应用程序引擎配置,您可以直接调试和运行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,然后在您的Python和谷歌应用程序引擎版本中创建GAE项目并将PyDev指向您的版本。

#5


2  

appengine 1.31
Django 1.1
pydev 1.5.4
OS Ubuntu 9.10

appengine 1.31 Django 1.1 pydev 1.5.4 OS 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 -主要。py -管理。py - .project - .pydevproject -设置。py(无法装载)- urls.py


main.py:

main.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', 'elvis@gmail.com'),
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

eclipse运行:/usr/bin/python2.6 -u /home/elvis/google_appengine/dev_appserver.py

The PYTHONPATH that will be used is:

将使用的python路径是:

/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 /插件/ org.python.pydev_1.5.4.2010011921 / PySrc / pydev_sitecustomize:/ home /猫王/ workspace / pythonleggo:/ home /猫王/ google_appengine:/ home /猫王/ google_appengine / lib / webob:/ home /猫王/ 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 /公益诉讼:/ 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 /地方/ 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加载设置文件。环境[' DJANGO_SETTINGS_MODULE ']=“设置”。它似乎被从django接收到的环境中删除了。我使用的设置。配置哪个看起来工作正确。此时,我只在appspot中有默认的django页面加载。

#6


2  

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,所以这可能不太相关。不过,这对于弄清楚如何让它们一起工作可能仍然有用。你也可以看看这个博客。

#7


1  

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和谷歌应用程序引擎。我想我们都是用外参照的方式把头撞在了同一面墙上。

I've tried deploying the google-app-engine-django project 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/谷歌文件夹添加为外部引用。

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.

通常,这对我来说都是有意义的。每个都包含了初始__。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的直接文件夹。要正确引用包,您需要导入包含包duh的父文件夹!这也意味着,因为我不想使用/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.

做完这些,一切都进展顺利。我想这是为了表明我还有更多的阅读要做。

#8


0  

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- python- world-example-us -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

我希望这能帮助那些刚刚起步的人