views:

6386

answers:

6

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

+8  A: 

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

Sam
Thanks - yes, that article is relevant for Eclipse/GAE but not for the particulars of Eclipse/GAE/Django.
Pydev has inbuilt GAE support: http://stackoverflow.com/questions/523841/django-pydev-eclipse-google-app-engine-possible/872587#872587
Casebash
A: 

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.

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.

I've added them as source folders, and I've added the /google_appengine/google folder as an external reference.

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.

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.

With that done, everything is running smoothly. I guess it's to show I have more reading up to do on Py.

kRON
+3  A: 

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.

http://www.alishabdar.com/2009/05/06/develop-google-appengine-with-aptana-studio/

Ali Shabdar
Why Aptana than Eclipse?
Lakshman Prasad
+4  A: 

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

Fabio Zadrozny
+2  A: 

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.

Casebash
+1  A: 

appengine 1.31
Django 1.1
pydev 1.5.4
OS Ubuntu 9.10


eclipse .pydevproject file:

<?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


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', '[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

The PYTHONPATH that will be used is:

/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.

jon
Why are you using 2.6? App Engine only supports 2.5
Casebash