1. Reid van Melle
  2. gondor_starter


This is a very simple starting point for a gondor.io project meant to be used for building mobile APIs using Django >= 1.3.0.  Everything can be modified of course.  I was just hoping to give somebody a headstart and avoid a few of the problems I encountered when getting started with gondor.  I'm assuming you are using virtualenv and pip.  This tutorial is also mercurial based (you can use it on git with only a couple of minor modifications).

- django-tokenapi project for mobile API authentication (https://github.com/jpulgarin/django-tokenapi)
- south for migrations
- sqlite for DB

Another useful resource which I used for much of this: http://kencochrane.net/blog/2011/04/my-day-gondorio/

Setup your Gondor credentials in '~/.gondor'.  This is adequately explained in the gondor docs or from the link above.  You should also create a Gondor site as explained in the gondor docs.

Create a virtualenv:

$ mkvirtualenv gondor  [call this what you want]
$ pip install --update -r www/requirements/project.txt

Additional changes you will need to make:

- edit "www/.gondor/config" and enter your site key
- optionally modify the 'vcs' setting in config if you would rather use git

To create your gondor instance, and deploy:

$ gondor create master
$ gondor deploy master default [the branch name 'default' is specific to mercurial]

Then create your django admin user:

$ gondor run master createsuperuser

Once you have your server up and running, you can verify that the the authentication is working with the superuser credentials set from above.  This first command creates a new token which by default persists for 7 days.

$ curl -d "username=<username>&password=<password>" http://<gondor_site_name>/token/new.json

{"success": true, "token": "2uy-420a8efff7f882afc20d", "user": 1}

To verify that the token is valid and working, we use the user ID and token pair:

$ curl http://<gondor_site_name>/token/2uy-420a8efff7f882afc20d/1.json