Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google App Engine and Django support

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.

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

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.

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?

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.

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

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

like image 882
Roger Avatar asked Jan 03 '13 10:01

Roger


Video Answer


1 Answers

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/

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

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

like image 64
hansaplast Avatar answered Nov 15 '22 08:11

hansaplast