Source

dotcloud_starter /

Filename Size Date modified Message
static
www
76 B
3.2 KB
692 B
54 B
523 B
This is a very simple starting point for a dotcloud 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 dotcloud.  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).  An important note is that you must remember to commit your changes before you push to dotcloud since it uses the last committed version when it finds a mercurial or git repot.

- piston for mobile API creation (https://bitbucket.org/jespern/django-piston/)
- south for migrations
- sqlite for DB  [this is just to avoid some extra distracting steps while getting started]

The main resources I used for this were a blog post by Ken Cochrane and the excellent dotcloud document as well.

- http://kencochrane.net/blog/2011/04/deploying-my-django-application-to-dotcloud/
- http://docs.dotcloud.com/tutorials/django/

For a simple testapp, I was building some of the basic models etc. from here:

- http://docs.djangoproject.com/en/dev/intro/tutorial03/?from=olddocs

=== Some initial standard setup ===

Create a virtualenv:

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

$ dotcloud create <project>
$ dotcloud deploy -t python <project>.www
$ dotcloud push <project>.www .  [assuming you're in the toplevel dir]

=== Get Sunk and Migratized === 

$ dotcloud run <project>.www python current/www/manage.py syncdb
$ dotcloud run <project>.www python current/www/manage.py migrate

VISIT  "http://www.<project>.dotcloud.com"

=== Load some fixture data ===

$ dotcloud run <project>.www python current/www/manage.py loaddata current/www/fixtures/myapp.json

=== Try out the API ===

$ curl http://www.<project>.dotcloud.com/api/polls
Authorization Required
$ curl --user <username>:<password> http://www.<project>.dotcloud.com/api/polls
[
    {
        "question": "This is a great question", 
        "choices": [
            {
                "votes": 5, 
                "choice": "choice 1"
            }, 
            {
                "votes": 2, 
                "choice": "Choice 2"
            }
        ]
    }
]

=== A quick note ===

If you looking in the settings.py, you will notice that the sqlite DB location, has an absolute path which will not work for local development.  However, there is an override for local_settings.py file.  I have something like the following in mine:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': '<project>.db',                      # Or path to database file if using sqlite3.
        'USER': '',                      # Not used with sqlite3.
        'PASSWORD': '',                  # Not used with sqlite3.
        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
    }
}

ADMIN_MEDIA_PREFIX = '/static/admin/'