Pre-requsite
- Install eclipse 3.8 Platform Runtime Binary
http://download.eclipse.org/eclipse/downloads/drops/R-3.8-201206081200/ - Install Aptana Studio 3 eclipse plugin : http://download.aptana.com/studio3/plugin/install
- Install Google App Engine
- Install Python 2.7.2,
- Install Django 1.3, don't install 1.4.x that still not supported by GAE untill now.
- Download Django-nonrel engine (djangoappengin)
- Add %python2.7_home%\Scripts to path (that we need to access dango-admin.py)
Create a new test project
- Under eclipse workspace directory run : django-admin.py startproject gdjtest
- New a 'PyDev Google App Engine Project' from eclipse, named 'gdjtest'
- New a GEA configuration file under project root : app.yaml, with content as below
application: gdjtest
version: 1
runtime: python27
api_version: 1
threadsafe: yes
libraries:
- name: django
version: 1.3
- url: /.*
script: djangoappengine.main.application - Copy djangoappengin from django-nonrel to project root directory
- Start up GAE Django server : project submenu:[Run As][PyDev:Google App Run]
- Use browser to test : http://localhost:8080/
- If success, got the page response as below :
It worked!
Congratulations on your first Django-powered page.
Of course, you haven't actually done any work yet. Here's what to do next:- If you plan to use a database, edit the
DATABASES
setting insettings/settings.py
. - Start your first app by running
python settings/manage.py startapp [appname]
.
You're seeing this message because you haveDEBUG = True
in your Django settings file and you haven't configured any URLs. Get to work! - If you plan to use a database, edit the
Error Debugging
- App server startup fail : No URLMap entries found in application configuration
app.yaml loss handlers section
handlers:
- url: /.*
script: djangoappengine.main.application - ImportError: No module named django.conf
app.yaml lose django libraries
libraries:
- name: django
version: 1.3 - ImportError: No module named gdjtest.urls
Modify settings.py, find line ROOT_URLCONF = 'gdjtest.urls' and change to ROOT_URLCONF = 'urls'
Complete app.yaml for Django on GAE:
application: optionwatch
version: 1
runtime: python27
api_version: 1
threadsafe: yes
builtins:
- remote_api: on
inbound_services:
- warmup
libraries:
- name: django
version: 1.3
- name: lxml
version: latest
handlers:
- url: /_ah/queue/deferred
script: djangoappengine.deferred.handler.application
login: admin
- url: /_ah/stats/.*
script: djangoappengine.appstats.application
- url: /media/admin
static_dir: django/contrib/admin/media
expiration: '0'
- url: /.*
script: djangoappengine.main.application
沒有留言:
張貼留言