Full Stack Django on Google App Engine (abbreviated) at Austin PUG February 10, 2010 Percy Wegmann presenting
The Problem You want to run a recent version of Django on Google App Engine.
Solution 1 – Django app-engine-patch http://code.google.com/p/app-engine-patch/ <ul><li>Supports authentication framework
Supports session management and caching backend
Supports admin interface
Supports Django forms
Supports a bunch of other things as well
Upcoming SlideShare
Loading in …5
×

Full Stack Django On Google App Engine

3,095 views

Published on

Presentation discussing how to run Django on Google's App Engine, presented to the Austin Python Users' Group on February 10, 2010.

Published in: Technology, News & Politics
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,095
On SlideShare
0
From Embeds
0
Number of Embeds
38
Actions
Shares
0
Downloads
34
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Full Stack Django On Google App Engine

  1. 1. Full Stack Django on Google App Engine (abbreviated) at Austin PUG February 10, 2010 Percy Wegmann presenting
  2. 2. The Problem You want to run a recent version of Django on Google App Engine.
  3. 3. Solution 1 – Django app-engine-patch http://code.google.com/p/app-engine-patch/ <ul><li>Supports authentication framework
  4. 4. Supports session management and caching backend
  5. 5. Supports admin interface
  6. 6. Supports Django forms
  7. 7. Supports a bunch of other things as well
  8. 8. Can be slow because it is almost a complete drop-in replacement for Django (and all of those modules need to get loaded by App Engine) </li></ul>
  9. 9. Solution 2 – Built-in Django 1.1 with App Engine Helper http://code.google.com/appengine/docs/python/tools/libraries.html http://code.google.com/p/google-app-engine-django/ <ul><li>Supports authentication framework
  10. 10. Supports session management and caching backend
  11. 11. Does not support admin interface (App Engine has its own admin)
  12. 12. Does not support Django forms (App Engine has its own forms)
  13. 13. Faster than app-engine-patch because Django 1.1 is supported by App Engine as a preloaded built-in </li></ul>
  14. 14. How it Works - main.py import os (os.environ)[ 'DJANGO_SETTINGS_MODULE' ] = 'settings' # Standard Python imports. import sys from appengine_django import InstallAppengineHelperForDjango InstallAppengineHelperForDjango( &quot;1.1&quot; ) from appengine_django import have_django_zip from appengine_django import django_zip_path # Google App Engine imports. from google.appengine.ext.webapp import util # Import the part of Django that we use here. import django.core.handlers.wsgi def main (): # Ensure the Django zipfile is in the path if required. if have_django_zip and django_zip_path not in sys.path: sys.path.insert( 1 , django_zip_path) # Create a Django application for WSGI. application = django.core.handlers.wsgi.WSGIHandler() # Run the WSGI CGI handler with that application. util.run_wsgi_app(application) if __name__ == '__main__' : main()
  15. 15. How it Works – static media handling I put my static media in the folder static in my project root Then I define static_dir entries in app.yaml - url: /static/4 static_dir: static/ - url: /static static_dir: static/ - url: /.* script: main.py And in settings.py I define a MEDIA_ROOT setting that points at this path MEDIA_URL = “/static/4” for external permalinks versioned to allow media changes dynamic Django urls
  16. 16. How it Works – app.yaml application: bidtective2 version: 1 runtime: python api_version: 1 default_expiration: '7d' handlers: - url: /remote_api script: $PYTHON_LIB/google/appengine/ext/remote_api/handler.py secure: optional login: admin # The below handler is required by bigtable search - url: /bts/.* script: bts/main.py secure: optional login: admin - url: /admin/.* script: main.py secure: optional login: admin - url: /task/.* script: main.py secure: optional login: admin - url: /static/4 static_dir: static/ - url: /static static_dir: static/ - url: /.* script: main.py

×