Just a simple prototype to learn backbone.js & knockout.js and try out django-tastypie and django-rest-framework.
- backbone.js - http://documentcloud.github.com/backbone/#
- knockout.js - http://knockoutjs.com/
- django-tastypie - http://tastypieapi.org/
- django-rest-framework - http://django-rest-framework.org/
-
Set up a Virtualenv
$ virtualenv venv --distribute
-
Install the required packages
$ pip install -r requirements.txt
NOTE: Mac OS X users may need to install libevent in order to install the gevent library. That library is only required if you will be running gunicorn. You can install it from a port, build it locally or remove that line from requirements.txt if you won't be using gunicorn
-
Create a DB and username (PostgreSQL) for the project
-
Create a new file called
local_settings.py
in the same directory assettings.py
. Copy the database block fromsettings.py
intolocal_settings.py
and replace the DB information with your own.DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. 'NAME': 'backbonetest', # Or path to database file if using sqlite3. 'USER': 'backbonetest', # Not used with sqlite3. 'PASSWORD': 'backbonetest', # Not used with sqlite3. 'HOST': '127.0.0.1', # Set to empty string for localhost. Not used with sqlite3. 'PORT': '', # Set to empty string for default. Not used with sqlite3. } }
-
Add the following 2 lines to
local_settings.py
to use local storage for static files rather than S3 storageSTATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage' STATIC_URL = '/static/'
-
Create the DB tables
$ python manage.py syncdb
-
Populate some test data
$ python manage.py loaddata cities_states
-
Run the app
$ python manage.py runserver
-
Test the UI
- backbone.js - http://localhost:8000/
- knockout.js - http://localhost:8000/ko/