Installation¶
Download latest Google AppEngine SDK¶
Get the latest version of SDK, if you are using Linux please make sure that SDK is available on your PATH (how?).
Install Django¶
Install Django framework. There are many ways of doing that (suggested one is to use virtualenv along with virtualenvwrapper and pip)
$ pip install django==1.3.1
Note
Version 1.3.1 is latest supported by SDK
Create Django project¶
Create new, awesome Django project, right now even more awesome because this project will use AppEngine:
$ django-admin startproject my_awesome_project
Install django-rocket-engine¶
Install latest version of django-rocket-engine, with pip
$ pip install django-rocket-engine
Create CloudSQL database¶
Create a CloudSQL database instance using Google Api Console, add application instance name from prevoius step in “Authorized applications”. Using “SQL Prompt” tab create a database inside your CloudSQL instance.
CREATE DATABASE database_name;
Configuration¶
Google AppEngine requires applications to have an config in app.yaml file, which is responsible for basic description, how to manage application. Create app.yaml inside project directory. Example app.yaml for project.
# app.yaml
application: unique_appengine_appspot_id
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: rocket_engine.wsgi
libraries:
- name: django
version: 1.3
env_variables:
DJANGO_SETTINGS_MODULE: 'settings'
Very list bit that needs to be done is to modify settings. Things that need to be done are presented in code snippet bellow:
# settings.py
from rocket_engine import on_appengine
...
# django-rocket-engine as every Django application
# needs to be added to settings.py file in INSTALLED_APPS section:
INSTALLED_APPS = (
# other django applications here
# ...
'rocket_engine',
)
# remove project name from ROOT_URLCONF.
# AppEngine doesn't treat project as a module
# like normal Django application does.
ROOT_URLCONF = 'urls'
# to use different databases during
# development process and on production.
if on_appengine:
DATABASES = {
'default': {
'ENGINE': 'rocket_engine.db.backends.cloudsql',
'INSTANCE': 'instance:name',
'NAME': 'database_name',
}
}
else:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'development.db'
}
}
# disable debugging on production
DEBUG = not on_appengine
Note
Instead of using sqlite3 backend your are able to use MySQL backend. This should be also your choice for serious applications.
This is just about it, application is ready to run:
$ python manage.py syncdb
$ python manage.py runserver
and deploy:
$ python manage.py on_appengine syncdb
$ python manage.py appengine update --oauth2
Have fun!