Tuesday, February 17, 2009

Django on Google App Engine: How to Set Up Eclipse for Local Testing

The Django Helper Application

The Google App Engine supports Django, which is a great way to build a UI.  Getting it set up is a bit tricky if you're using a database, though, since Django has some different expectations about how you will interact with a DB.  Fortunately the good people at Google have provided a Django project to help with this.  Their instructions are on  this page.


This post doesn't tell you anything that you can't find elsewhere - I just pulled it from one of my OneNotes pages to share because it is a bit more concise, and it also has a couple of screen caps from Eclipse.

 

Local Django Configuration in Eclipse

To start your app:

  • Go to the directory where you want to create your app, and run "django-admin.py startproject mysite" where "mysite" is the name of your app.
  • Navigate to the directory where "manage.py" lives for your app.
  • Make sure that app-yaml has an app name in it (pretty much anything will work, I think).
  • Fire up the local Django app server with "python manage.py runserver".
  • To see your app on the local server, go to: http://localhost:8000/.
  • To see the local admin console, go to: http://localhost:8000/_ah/admin/.


 

To add a new view / URL in Django (for more details, see the example from the Django tutorial):


1) Add a new function to views.py

 


 2) Add a regex and the function to urls.py

 


 


 

 

That pretty much does it.  I found that this worked well & gave me really good debugging capabilities (the local Django gives excellent information when debugging is turned on - which is by default).
Post a Comment