Question

What is the best approach to use EAK and ember-data-tastypie-adapter?

I am currently trying the following:

  • Django running on localhost:7000
  • EAK running on localhost:8000
  • Added ember-data-tastypie-adapter to bower.json
  • Added both JS files to index.html

    <script src="/vendor/ember-data-tastypie-adapter/packages/ember-data-tastypie-adapter/lib/tastypie_adapter.js"></script>
    <script src="/vendor/ember-data-tastypie-adapter/packages/ember-data-tastypie-adapter/lib/tastypie_serializer.js"></script>
    
  • Created everything needed on Django side

I figured that I had to create serializers/application.js and put in it:

export default DS.DjangoTastypieSerializer.extend();

Also adapters/application.js needed adjustments:

export default DS.DjangoTastypieAdapter.extend({
    serverDomain: 'http://localhost:7000',
});

Requests go to Django and responses are sent. However in EAK this gives "Sorry, something went wrong" message without any further information (empty error message box). No errors in console either.

If I remove serializers/application.js I get similar message, in this case with information about the error:

Assertion Failed: Nested controllers need be referenced as [/django/tastypie],
instead of [_djangoTastypie].
Refer documentation: http://iamstef.net/ember-app-kit/guides/naming-conventions.html

Do I have to define defaultSerializer in adapters/application.js? If so, what is it, /django/tastypie or something else?

What am I missing to integrate ember-data-tastypie-adapter in EAK? Trouble is, I have not seen any example where EAK and tastypie would be working together.

Of course this two local server system is development environment. Production is planned like here, both API and JS is served by one Django instance.

UPDATE: Creating deployment code by grunt dist and serving it using Django works.

I suspect that problem lies with different JSON origin.

Was it helpful?

Solution

Turns out, that EAK has API proxy option.

Updated package.json to my API settings:

"proxyURL": "http://localhost:7000",
"proxyPath": "/api/v1",

Removed custom settings from adapters/application.js.

Now running grunt server:proxy gets data from Django. And ember.js app works without errors, not being same origin was most likely the problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top