Clean up API views / improve caching

Huge refactor of views_api.py. Could be abstracted further but not worth the effort for now. Also upgrade to django 1.6.