django-nonrel and Google App Engine buildout
Easily install and manage django-nonrel based Google App Engine applications using buildout command.
The buildout configuration uses Mr. Developer extension to pull all
djangoappengine bits together and set-up them for you, so you can instantly start developing
Google App Engine applications.
This buildout is supported only on UNIX based systems.
buildout.cfg configuration file to describe how to set up a Python software project
- Download required dependencies from PyPi (Python egg packages)
- Checkout and manage source code from version control systems - public and your private repositores
- Create start up scripts and set environment variables
Buildout benefits include
- Repeatability: All project developers can start quickly (no more one day setting up dependencies)
- Repeatability: Easily move your project between different folders, computers or servers
- Standard: Part of advanced Python developer toolkit. Provides more reusability than ad hoc shell scripts.
Buildout works around some Google App Engine deployment problems.
This buildout will check out a sample Google App Engine + django-nonrel application called
To work with your own project, just make your Django application available
django-nonrel over stock Google App Engine modules and templates provide additional benefits
- Maintained versions: Google App Engine stock Python modules are old
- Vendor independence: You can move your code to some other NoSQL or SQL database on one day
- Reuse: You can plug-in existing Django applications and modules easily. With buildout, it is just including the package egg name in buildout.cfg file and the Django application will be downloaded for you automatically.
You need to know basics of working with UNIX command line.
You need to have installed
- Google App Engine SDK for Python
- git command
- hg command (Mercurial tools)
- Python, at least 2.5
Your OS Python setuptools or Distribute (setuptools replacement) package which is used to automatically download and install packages from PyPi repository, must be new enough version or you get funny error messages.
To install Distribute, use your OS package or follow instructions here.
Clone this project from Github according to Github instructions.
Run bootstrap.py to generate
- Then make buildout to do the all the hard work of downloading and setting up configuration files for you::
You need to re-run buildout command if you change
settings.py. This is because
settings.py is copied to generated directory under
Before running App Engine version of Django, make sure Google App Engine is included in your shell environment command PATH. This step is only needed if you have Google App Engine SDK in non-standard location:
>Now you can run django-admin wrapper which is configured to used Python package setup as described in
bin/django --version 1.3 alpha 1
You also see that Google App Engine specific commands in the management:
bin/django --help Usage: django subcommand [options] [args] Options: -v VERBOSITY, --verbosity=VERBOSITY Verbosity level; 0=minimal output, 1=normal output, ... Available subcommands: changepassword cleanup compilemessages ... remote
The buildout ships with a sample project skeleton called
my.sampleproject. You can clone this
skeleton and modify it to start building your won application.
Start Google App Engine service with a sample database:
Never run manage.py runserver together with other management commands at the same time. The changes won't take effect. That's an App Engine SDK limitation which might get fixed in a later release.
To deploy your application on Google App Engine you can use command:
bin/django deploy --nosyncdb
--nosyncdb argument will tell deploy not to run Django syncdb command (creating initial models and stuff)
against the production database.
If you are using the sample application for testing you need at least change Google App Engine application id in src/my.sampleproject/my/sampleproject/app.yaml.
Currently the suggested way to reuse is this buildout is just to make your own copy of it and put in your own project to
- eggs section - you need to package your Python source code as egg (see
- Alternative you need to put source code eggs to
[buildout]section or use
[sources]section and Mr. Developer to manage the checkout
... or as a dummy alternative, replace
my.samplerproject everywhere with your own package name.
When you run
[flatten-eggs] recipe will create a flat, symlinked, directory
structure of available eggs. This makes the code deployable on Google App Engine,
because App Engine does not support egg deployments. Later, this flattened folder is added
my.sampleproject, making eggs importable.
flattened-eggs folder is automatically cleared, so if you remove eggs, you do not need to purge the folder manually.
Currently uses patched
djc.recipe packages. Patches pushed upstream / merge requests created.
- Contact mikko at mfabrik dot com
- Follow in Twitter
If you get this message when deploying:
google.appengine.api.datastore_errors.NeedIndexError: The index for this query is not ready to serve. See the Datastore Indexes page in the Admin Console. This query needs this index: - kind: django_content_type properties: - name: app_label - name: name
It means that syncdb has not succeeded. Google App Engine is still working to build indexes for your datastore entities. You can go to App Engine Dashboard and see that there should be label Building for this index.