2012年10月12日 星期五

GAE - Python Development Test 2 - Using Django Framework

Pre-request:

  1. Python2.7 is installed
  2. Google App Engine SDK is install (Here version 1.7.2 is used)
  3. Add the google_appengine folder(ex. d:\Google\google_appengine)to your PATH
  4. Django 1.3 is installed (Don't use 1.4.x, the latest version of Dgango, because GAE support 1.3 only on the time of this post)
  5. Add python scripts to PATH, that should include django-admin.py (ex. d:\dev\python2.7\Scripts)
PS. This post is tested under Windows environment.

Create GAE project with Django (1.3 supported, currently) enabled:

  1. Create a new Google App Engine project:
    menu[File:New:Project...] => dialog:tree[PyDev-PyDev Google App Engine Project]:button[next] => dialog:label[Project Nam:text["gtest"]:button[next] => dialog:label[Google App Engine Directory]:button[Browser] => file_browser[D:\Dev\Google\google_appengine] :dialog:button[OK]:button[Next] => label[What's the application id ...]:text["gtest"]:label[From which template ...]:list[Empty Project]:button[Finish]
  2. Download Django-norel related zip file, and extract them,  for Django enabled on GAE, that did use non-RDB (bigtable) as backend database)
    1. django-nonrel : Django-nonrel is an attempt at fixing the problems and simplifying NoSQL development by adding support for NoSQL DBs to Django's ORM.
    2. djangoappengine : Contains all App Engine backends for Django-nonrel (database, email, etc.).
    3. djangotoolbox : A sandbox for Django-nonrel extra features.
    4. django-autoload : django-autoload is a reuseable django app which allows for correct initialization of your django project.
    5. django-dbindexer : Simplify your NoSQL model code and get advanced SQL-like features on non-relational databases.
    6. django-testapp
  3. Copy folders to project root directory from all above :
    1. Copy django-nonrel/django to %project%/django
    2. Copy djangotoolbox/djangotoolbox to %project%/djangotoolbox
    3. Copy django-autoload/autoload to %project%/autoload
    4. Copy django-dbindexer/dbindexer to /dbindexer
    5. Copy djangoappengine to /djangoappengine link
    6. Copy django-testapp/*.py & *.yaml to %project%/
    7. Copy django-testapp/template to %project/template
  4. Test run testapp in GAE and with Django enabled
    right click on project:menu[Run As][1.PyDev:Google App Run]
    console message:
    INFO 2012-10-12 07:00:33,980 dev_appserver_multiprocess.py:655] Running application dev~ctst on port 8080: http://localhost:8080
    INFO 2012-10-12 07:00:33,980 dev_appserver_multiprocess.py:657] Admin console is available at: http://localhost:8080/_ah/admin
  5. Start up browser and access http://localhost:8080, and can get first line message :

    It works!

    Your Django-nonrel installation is working fine. Now go and build something useful with it. :

沒有留言: