Ember-CLI and Django Tastypie

Just a quick note to remember myself how to connect ember-cli and the django-tastypie-adapter.

  1. Install the adapter with bower (—save is important)
bower install —save ember-data-tastypie-adapter

2. Import files into “brocfile.js”

var app = new EmberApp();
app.import(‘vendor/ember-data-tastypie-adapter/packages/ember-data-tastypie-adapter/lib/tastypie_adapter.js’);
app.import(‘vendor/ember-data-tastypie-adapter/packages/ember-data-tastypie-adapter/lib/tastypie_serializer.js’);

3. Create a new file and directory in app-directory: adapters/application.js with following content:

import DS from “ember-data”;
var ApplicationAdapter = DS.DjangoTastypieAdapter.extend({
 host: ‘http://localhost:8000',
 namespace: ‘api/v1'
});
export default ApplicationAdapter;

3. Create a new file and directory in app-directory: serializers/application.js with following content:

import DS from “ember-data”;
export default DS.DjangoTastypieSerializer.extend();

4. Install “corsheaders” for django and set middleware in settings.py for cross domain requests:

‘corsheaders.middleware.CorsMiddleware’,
‘django.middleware.common.CommonMiddleware’,

5. Set

CORS_ORIGIN_ALLOW_ALL = True 

or write whitelist

Show your support

Clapping shows how much you appreciated Sven Schannak’s story.